Browse Source

PonySocks 2.1

master
Adrian Siekierka 2 years ago
parent
commit
21530f65da
34 changed files with 1221 additions and 393 deletions
  1. 22
    0
      Jenkinsfile
  2. 11
    0
      README.md
  3. 87
    63
      build.gradle
  4. 7
    0
      docs/licenses/LICENSE
  5. 87
    16
      src/main/java/pl/asie/ponysocks/ClientProxy.java
  6. 13
    3
      src/main/java/pl/asie/ponysocks/CommonProxy.java
  7. 51
    48
      src/main/java/pl/asie/ponysocks/ItemSock.java
  8. 0
    230
      src/main/java/pl/asie/ponysocks/PonyRenderListener.java
  9. 90
    27
      src/main/java/pl/asie/ponysocks/PonySocks.java
  10. 16
    6
      src/main/java/pl/asie/ponysocks/RecipeSockColor.java
  11. 96
    0
      src/main/java/pl/asie/ponysocks/recipe/RecipeBase.java
  12. 178
    0
      src/main/java/pl/asie/ponysocks/recipe/RecipeDyeableBase.java
  13. 54
    0
      src/main/java/pl/asie/ponysocks/recipe/RecipeSockClear.java
  14. 51
    0
      src/main/java/pl/asie/ponysocks/recipe/RecipeSockCreate.java
  15. 93
    0
      src/main/java/pl/asie/ponysocks/recipe/RecipeSockPaint.java
  16. 53
    0
      src/main/java/pl/asie/ponysocks/recipe/RecipeSockRainbow.java
  17. 60
    0
      src/main/java/pl/asie/ponysocks/recipe/jei/JEIRecipePony.java
  18. 44
    0
      src/main/java/pl/asie/ponysocks/recipe/jei/PonySocksJEIPlugin.java
  19. 17
    0
      src/main/java/pl/asie/ponysocks/render/IStackedArmor.java
  20. 26
    0
      src/main/java/pl/asie/ponysocks/render/ItemSockColor.java
  21. 64
    0
      src/main/java/pl/asie/ponysocks/render/ModelArmorSock.java
  22. 58
    0
      src/main/java/pl/asie/ponysocks/render/ModelArmorSockBiped.java
  23. 21
    0
      src/main/resources/assets/ponysocks/blockstates/sockitem.json
  24. 0
    0
      src/main/resources/assets/ponysocks/lang/en_us.lang
  25. BIN
      src/main/resources/assets/ponysocks/textures/armor/sock_layer_fake.png
  26. BIN
      src/main/resources/assets/ponysocks/textures/items/icon_sock_rainbow.png
  27. BIN
      src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_0.png
  28. 0
    0
      src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_0_pony.png
  29. BIN
      src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_1.png
  30. 0
    0
      src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_1_pony.png
  31. BIN
      src/main/resources/assets/ponysocks/textures/models/armor/sock_rainbow.png
  32. BIN
      src/main/resources/assets/ponysocks/textures/models/armor/sock_rainbow_pony.png
  33. 16
    0
      src/main/resources/mcmod.info
  34. 6
    0
      src/main/resources/pack.mcmeta

+ 22
- 0
Jenkinsfile View File

@@ -0,0 +1,22 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'rm -f private.gradle'
sh './gradlew setupCiWorkspace clean build'
archive 'build/libs/*jar'
}
}
stage('Deploy') {
steps {
withCredentials([file(credentialsId: 'privateGradleNoSnapshot', variable: 'PRIVATEGRADLE')]) {
sh '''
cp "$PRIVATEGRADLE" private.gradle
./gradlew upload
'''
}
}
}
}
}

+ 11
- 0
README.md View File

@@ -0,0 +1,11 @@
This is the GitHub repository for PonySocks.

## Compiling

Compiling this is a bit tricky.

1. Create a "libs" directory.
2. Clone [the MineLittlePony repository](https://github.com/MineLittlePony/MineLittlePony/).
3. Run "gradle build"
4. Copy the "-srg.jar" to "libs" and deobfuscate using BON2.
5. From here on, create your workspace as usual.

+ 87
- 63
build.gradle View File

@@ -1,63 +1,87 @@
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}

apply plugin: 'forge'

version = "2.0"
group= "pl.asie.ponysocks" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "PonySocks"

minecraft {
version = "1.7.10-10.13.4.1492-1.7.10"
runDir = "eclipse"
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"
// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}

processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "gradle.plugin.net.minecrell:licenser:0.3"
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'net.minecrell.licenser'
version = "2.1"
group = "pl.asie.ponysocks"
archivesBaseName = "PonySocks"
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
if (System.getenv("BUILD_NUMBER") != null)
version += ".${System.getenv("BUILD_NUMBER")}"
configurations {
deploy
}
dependencies {
deploy 'org.apache.maven.wagon:wagon-ssh:2.10'
}
minecraft {
version = "1.12.1-14.22.1.2484"
runDir = "run"
mappings = "snapshot_20170917"
}
repositories {
maven {
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
}
sourceSets {
main {
resources {
srcDirs += 'docs'
}
}
}
license {
sourceSets = [project.sourceSets.main]
header = project.file("docs/licenses/LICENSE")
ignoreFailures = true
exclude '**/*.lang'
exclude '**/*.info'
exclude '**/*.mcmeta'
}
dependencies {
deobfCompile "mezz.jei:jei_1.12.1:4.7.8.95"
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version':project.version, 'mcversion':project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
if (file('private.gradle').exists()) {
apply from: 'private.gradle'
}

+ 7
- 0
docs/licenses/LICENSE View File

@@ -0,0 +1,7 @@
Copyright (C) 2015, 2017 Adrian Siekierka

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 87
- 16
src/main/java/pl/asie/ponysocks/ClientProxy.java View File

@@ -1,30 +1,101 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks;

import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import pl.asie.ponysocks.render.IStackedArmor;
import pl.asie.ponysocks.render.ItemSockColor;
import pl.asie.ponysocks.render.ModelArmorSockBiped;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraftforge.common.MinecraftForge;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

public class ClientProxy extends CommonProxy {
@Override
public int getRenderIndexArmor(String prefix) {
if (prefix == null) {
return 0;
private static final ModelResourceLocation[] modelTypes = {
new ModelResourceLocation("ponysocks:sockitem","inventory"),
new ModelResourceLocation("ponysocks:sockitem","inventory_rainbow")
};

private static ModelBiped modelArmorHuman, modelArmorPony;

public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, EntityEquipmentSlot armorSlot, ModelBiped parentModel) {
ModelBiped targetModel = null;

if (modelArmorHuman == null) {
modelArmorHuman = new ModelArmorSockBiped();
}

for (int i = 0; i < RenderBiped.bipedArmorFilenamePrefix.length; i++) {
if (prefix.equals(RenderBiped.bipedArmorFilenamePrefix[i])) {
return i;
if (!(parentModel.getClass().getName().startsWith("com.minelittlepony"))) {
if (armorSlot == EntityEquipmentSlot.FEET) {
targetModel = modelArmorHuman;
}
} else {
if (armorSlot == EntityEquipmentSlot.FEET) {
if (modelArmorPony == null) {
MethodHandle sockCreationHandle;

try {
Class.forName("com.minelittlepony.model.pony.armor.ModelPonyArmor");

try {
sockCreationHandle = MethodHandles.lookup().unreflectConstructor(Class.forName("pl.asie.ponysocks.render.ModelArmorSock").getConstructor());
} catch (Exception ee) {
throw new RuntimeException(ee);
}
} catch (Exception e) {
PonySocks.LOGGER.info("MineLittlePony not detected!");

try {
sockCreationHandle = MethodHandles.lookup().unreflectConstructor(Class.forName("pl.asie.ponysocks.render.ModelArmorSockBiped").getConstructor());
} catch (Exception ee) {
throw new RuntimeException(ee);
}
}

try {
modelArmorPony = (ModelBiped) sockCreationHandle.invoke();
} catch (Throwable t) {
throw new RuntimeException(t);
}
}

targetModel = modelArmorPony;
}
}
return RenderingRegistry.addNewArmourRendererPrefix(prefix);

((IStackedArmor) targetModel).setArmorStack(stack);
return targetModel;
}

@Override
public void preInit() {
ModelLoader.setCustomMeshDefinition(PonySocks.sock, stack -> modelTypes[stack.getMetadata() % modelTypes.length]);
ModelBakery.registerItemVariants(PonySocks.sock, modelTypes);
}

@Override
public void registerRenderers() {
PonyRenderListener prl = new PonyRenderListener();
MinecraftForge.EVENT_BUS.register(prl);
FMLCommonHandler.instance().bus().register(prl);
public void init() {
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new ItemSockColor(), PonySocks.sock);
}
}

+ 13
- 3
src/main/java/pl/asie/ponysocks/CommonProxy.java View File

@@ -1,11 +1,21 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks;

public class CommonProxy {
public int getRenderIndexArmor(String prefix) {
return 0;
public void preInit() {
}

public void registerRenderers() {
public void init() {

}
}

+ 51
- 48
src/main/java/pl/asie/ponysocks/ItemSock.java View File

@@ -1,68 +1,67 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.EnumHelper;
import pl.asie.ponysocks.render.ModelArmorSock;
import pl.asie.ponysocks.render.ModelArmorSockBiped;

public class ItemSock extends ItemArmor {
public static final ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("Sock", 4, new int[]{1, 1, 1, 1}, 5);
protected static boolean IS_SECOND_PHASE;
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleProxies;
import java.lang.invoke.MethodHandles;

@SideOnly(Side.CLIENT)
private IIcon[] icons;
public class ItemSock extends ItemArmor {
public static final ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("sock", "ponysocks:sock", 4, new int[]{1, 1, 1, 1}, 5, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F);

public ItemSock() {
super(MATERIAL, 0, 3);
super(MATERIAL, 0, EntityEquipmentSlot.FEET);
setCreativeTab(PonySocks.tabSocks);
setUnlocalizedName("ponysocks.sock");
}

@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if ("overlay".equals(type)) {
return "ponysocks:textures/armor/sock_layer_fake.png";
} else {
if (IS_SECOND_PHASE) {
return "ponysocks:textures/armor/sock_layer_1.png";
} else {
return "ponysocks:textures/armor/sock_layer_0.png";
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) {
for (int i = 1; i < 2; i++) {
ItemStack stack = new ItemStack(this, 1, 0);
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setInteger("type", i);
items.add(stack);
}
}
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
icons = new IIcon[3];
icons[0] = register.registerIcon("ponysocks:icon_sock_layer_0");
icons[1] = register.registerIcon("ponysocks:icon_sock_layer_1");
icons[2] = register.registerIcon("ponysocks:icon_sock_overlay");
items.addAll(PonySocks.getSocksOrdered());
}
}

@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses() {
return true;
}

@Override
public int getRenderPasses(int metadata) {
return 3;
}

@Override
public int getColor(ItemStack stack) {
return getColor(stack, IS_SECOND_PHASE);
@Nullable
public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, EntityEquipmentSlot armorSlot, ModelBiped parentModel) {
return ClientProxy.getArmorModel(entity, stack, armorSlot, parentModel);
}

private int getColor(ItemStack stack, boolean passTwo) {
public int getColor(ItemStack stack, boolean passTwo) {
NBTTagCompound compound = stack.getTagCompound();
String key = passTwo ? "color2" : "color1";

@@ -73,15 +72,19 @@ public class ItemSock extends ItemArmor {
}
}

@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass) {
return pass == 2 ? 16777215 : getColor(stack, pass == 1);
public boolean hasColor(ItemStack stack, boolean passTwo) {
NBTTagCompound compound = stack.getTagCompound();
String key = passTwo ? "color2" : "color1";

return compound != null && compound.hasKey(key);
}

public boolean isColorable(ItemStack stack) {
return stack.getMetadata() == 0;
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int damage, int pass) {
return icons[pass % 3];
public int getMetadata(ItemStack stack) {
return stack.hasTagCompound() && stack.getTagCompound().hasKey("type") ? stack.getTagCompound().getInteger("type") : 0;
}
}

+ 0
- 230
src/main/java/pl/asie/ponysocks/PonyRenderListener.java View File

@@ -1,230 +0,0 @@
package pl.asie.ponysocks;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;

/**
* Created by asie on 10/30/15.
*/
public class PonyRenderListener {
private float partialTicks;
private Method shouldRenderPassMethod, func_82408_cMethod;
private Field f;

public PonyRenderListener() {
try {
func_82408_cMethod = RendererLivingEntity.class.getDeclaredMethod("func_82408_c", EntityLivingBase.class, int.class, float.class);
func_82408_cMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}

try {
f = RendererLivingEntity.class.getDeclaredField("renderPassModel");
f.setAccessible(true);
} catch (NoSuchFieldException e) {
try {
f = RendererLivingEntity.class.getDeclaredField("field_77046_h");
f.setAccessible(true);
} catch (NoSuchFieldException ee) {
ee.printStackTrace();
}
}

try {
shouldRenderPassMethod = RendererLivingEntity.class.getDeclaredMethod("shouldRenderPass", EntityLivingBase.class, int.class, float.class);
shouldRenderPassMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
try {
shouldRenderPassMethod = RendererLivingEntity.class.getDeclaredMethod("func_77032_a", EntityLivingBase.class, int.class, float.class);
shouldRenderPassMethod.setAccessible(true);
} catch (NoSuchMethodException ee) {
ee.printStackTrace();
}
}
}
protected float getDeathMaxRotation(EntityLivingBase p_77037_1_)
{
return 90.0F;
}

protected void renderLivingAt(EntityLivingBase p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_)
{
GL11.glTranslatef((float)p_77039_2_, (float)p_77039_4_, (float)p_77039_6_);
}

protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_)
{
GL11.glRotatef(180.0F - p_77043_3_, 0.0F, 1.0F, 0.0F);

if (p_77043_1_.deathTime > 0)
{
float f3 = ((float)p_77043_1_.deathTime + p_77043_4_ - 1.0F) / 20.0F * 1.6F;
f3 = MathHelper.sqrt_float(f3);

if (f3 > 1.0F)
{
f3 = 1.0F;
}

GL11.glRotatef(f3 * this.getDeathMaxRotation(p_77043_1_), 0.0F, 0.0F, 1.0F);
}
else
{
String s = EnumChatFormatting.getTextWithoutFormattingCodes(p_77043_1_.getCommandSenderName());

if ((s.equals("Dinnerbone") || s.equals("Grumm")) && (!(p_77043_1_ instanceof EntityPlayer) || !((EntityPlayer)p_77043_1_).getHideCape()))
{
GL11.glTranslatef(0.0F, p_77043_1_.height + 0.1F, 0.0F);
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
}
}
}
private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_)
{
float f3;

for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F)
{
;
}

while (f3 >= 180.0F)
{
f3 -= 360.0F;
}

return p_77034_1_ + p_77034_3_ * f3;
}

protected float handleRotationFloat(EntityLivingBase p_77044_1_, float p_77044_2_)
{
return (float)p_77044_1_.ticksExisted + p_77044_2_;
}

@SubscribeEvent
public void onRenderStart(TickEvent.RenderTickEvent event) {
if (event.phase == TickEvent.Phase.START) {
partialTicks = event.renderTickTime;
}
}

private float playerPT;
private boolean playerPTPresent;

@SubscribeEvent
public void onRenderStart(RenderPlayerEvent.Pre event) {
playerPT = event.partialRenderTick;
playerPTPresent = true;
}

@SubscribeEvent
public void onEntityRenderPost(RenderLivingEvent.Post event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
ItemStack stack = player.getCurrentArmor(0);
if (stack != null && stack.getItem() instanceof ItemSock) {
ItemSock.IS_SECOND_PHASE = true;

GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_ALPHA_TEST);

try {
float p_76986_9_ = playerPTPresent ? playerPT : partialTicks;
playerPTPresent = false;

float f2 = this.interpolateRotation(player.prevRenderYawOffset, player.renderYawOffset, p_76986_9_);
float f3 = this.interpolateRotation(player.prevRotationYawHead, player.rotationYawHead, p_76986_9_);
float f4;

if (player.isRiding() && player.ridingEntity instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase1 = (EntityLivingBase)player.ridingEntity;
f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, p_76986_9_);
f4 = MathHelper.wrapAngleTo180_float(f3 - f2);

if (f4 < -85.0F)
{
f4 = -85.0F;
}

if (f4 >= 85.0F)
{
f4 = 85.0F;
}

f2 = f3 - f4;

if (f4 * f4 > 2500.0F)
{
f2 += f4 * 0.2F;
}
}

this.renderLivingAt(player, event.x, event.y, event.z);
float f13 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * p_76986_9_;
f4 = this.handleRotationFloat(player, p_76986_9_);
this.rotateCorpse(player, f4, f2, p_76986_9_);
float f5 = 0.0625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glScalef(-1.0F, -1.0F, 1.0F);
GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F);
float f6 = player.prevLimbSwingAmount + (player.limbSwingAmount - player.prevLimbSwingAmount) * p_76986_9_;
float f7 = player.limbSwing - player.limbSwingAmount * (1.0F - p_76986_9_);

if (player.isChild())
{
f7 *= 3.0F;
}

if (f6 > 1.0F)
{
f6 = 1.0F;
}

ModelBase renderPassModelT = (ModelBase) f.get(event.renderer);
if (renderPassModelT.getClass() != ModelBiped.class) {
GL11.glTranslatef(0, 0.25F + 0.125F, 0);
GL11.glScalef(0.75F, 0.75F, 0.75F);
} else {
GL11.glScalef(1 / 1.0625F, 1 / 1.0625F, 1 / 1.0625F);
GL11.glTranslatef(0, 0.09675F, 0);
}

shouldRenderPassMethod.invoke(event.renderer, player, 3, p_76986_9_);
ModelBase renderPassModel = (ModelBase) f.get(event.renderer);

renderPassModel.setLivingAnimations(player, f7, f6, p_76986_9_);
renderPassModel.render(player, f7, f6, f4, f3 - f2, f13, f5);
func_82408_cMethod.invoke(event.renderer, player, 3, p_76986_9_);
renderPassModel.render(player, f7, f6, f4, f3 - f2, f13, f5);
} catch (Exception e) {
e.printStackTrace();
}

GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();

ItemSock.IS_SECOND_PHASE = false;
}
}
}
}

+ 90
- 27
src/main/java/pl/asie/ponysocks/PonySocks.java View File

@@ -1,61 +1,124 @@
package pl.asie.ponysocks;
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import java.util.Random;
package pl.asie.ponysocks;

import java.util.*;

import com.google.common.collect.Lists;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.oredict.OreDictionary;
import pl.asie.ponysocks.recipe.*;

@Mod(modid = PonySocks.MODID, version = PonySocks.VERSION, acceptableRemoteVersions="*")
public class PonySocks {
private static final boolean DEBUG_LOGIN = false;

public static CreativeTabs tabSocks = new CreativeTabs("tabPonySocks") {
@Override
public ItemStack getIconItemStack() {
public ItemStack getTabIconItem() {
return new ItemStack(sock);
}

@Override
public Item getTabIconItem() {
return sock;
}
};

@SidedProxy(clientSide = "pl.asie.ponysocks.ClientProxy", serverSide = "pl.asie.ponysocks.CommonProxy")
public static CommonProxy proxy;

public static final int[] woolIds = new int[16];
public static final int[] dyeOreIds = new int[16];

public static final String MODID = "ponysocks";
public static final String VERSION = "2.0";
public static final Random RANDOM = new Random();
public static final Logger LOGGER = LogManager.getLogger("asietweaks");
public static final Logger LOGGER = LogManager.getLogger("ponysocks");

public static ItemSock sock;
public static Collection<IRecipe> specialDyeRecipes = new ArrayList<>();
private static List<ItemStack> socksOrdered;
private static List<ItemStack> socksShuffled;

private static void initSockLists() {
if (socksOrdered == null) {
socksOrdered = new ArrayList<>(256);

for (int i = 0; i < 256; i++) {
ItemStack sock = new ItemStack(PonySocks.sock, 1, 0);
sock.setTagCompound(new NBTTagCompound());
sock.getTagCompound().setInteger("color1", RecipeDyeableBase.fromFloats(EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(i & 15))));
sock.getTagCompound().setInteger("color2", RecipeDyeableBase.fromFloats(EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(i >> 4))));
socksOrdered.add(sock);
}

socksShuffled = Lists.newArrayList(socksOrdered);
Collections.shuffle(socksShuffled);
}
}

@EventHandler
public static List<ItemStack> getSocksOrdered() {
initSockLists();
return socksOrdered;
}

public static List<ItemStack> getSocksShuffled() {
initSockLists();
return socksShuffled;
}

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(proxy);

sock = new ItemSock();
GameRegistry.registerItem(sock, "sockItem");
sock.setRegistryName(new ResourceLocation(MODID, "sockitem"));

proxy.preInit();
}

@SubscribeEvent
public void onRegisterItems(RegistryEvent.Register<Item> event) {
event.getRegistry().register(sock);
}

@SubscribeEvent
public void onRegisterRecipes(RegistryEvent.Register<IRecipe> event){
event.getRegistry().register(new RecipeSockCreate(new ResourceLocation(MODID, "sock_create"), "ponysocks:sock"));
event.getRegistry().register(new RecipeSockPaint(new ResourceLocation(MODID, "sock_paint"), "ponysocks:sock"));
event.getRegistry().register(new RecipeSockClear(new ResourceLocation(MODID, "sock_clear"), "ponysocks:sock"));

specialDyeRecipes.add(new RecipeSockRainbow(new ResourceLocation(MODID, "sock_rainbow"), "ponysocks:sock"));

for (IRecipe recipe : specialDyeRecipes) {
event.getRegistry().register(recipe);
}
}

@EventHandler
public void init(FMLInitializationEvent event) {
proxy.registerRenderers();
proxy.init();
}

@EventHandler
@@ -81,10 +144,10 @@ public class PonySocks {
};

for (int i = 0; i < 16; i++) {
woolIds[i] = OreDictionary.getOreID("dye" + dyes[15 - i]);
dyeOreIds[i] = OreDictionary.getOreID("dye" + dyes[15 - i]);
}

GameRegistry.addShapedRecipe(new ItemStack(sock), "w w", "w w", 'w', Blocks.wool);
GameRegistry.addRecipe(new RecipeSockColor());
/* GameRegistry.addShapedRecipe(new ItemStack(sock), "w w", "w w", 'w', Blocks.wool);
GameRegistry.addRecipe(new RecipeSockColor()); */
}
}

+ 16
- 6
src/main/java/pl/asie/ponysocks/RecipeSockColor.java View File

@@ -1,3 +1,13 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks;

import java.util.ArrayList;
@@ -12,8 +22,8 @@ import net.minecraft.world.World;

import net.minecraftforge.oredict.OreDictionary;

public class RecipeSockColor implements IRecipe {
@Override
public class RecipeSockColor {
/* @Override
public boolean matches(InventoryCrafting crafting, World world) {
boolean foundSock = false;
int dyeCount = 0;
@@ -31,7 +41,7 @@ public class RecipeSockColor implements IRecipe {
int[] ids = OreDictionary.getOreIDs(s);
boolean found = false;
for (int ii : ids) {
for (int j : PonySocks.woolIds) {
for (int j : PonySocks.dyeOreIds) {
if (ii == j) {
found = true;
dyeCount++;
@@ -84,8 +94,8 @@ public class RecipeSockColor implements IRecipe {
int[] ids = OreDictionary.getOreIDs(s);
boolean found = false;
for (int ii : ids) {
for (int j = 0; j < PonySocks.woolIds.length; j++) {
if (ii == PonySocks.woolIds[j]) {
for (int j = 0; j < PonySocks.dyeOreIds.length; j++) {
if (ii == PonySocks.dyeOreIds[j]) {
int px = i % fWidth;
int py = i / fWidth;
if (px < sockX || (px == sockX && py < sockY)) {
@@ -211,5 +221,5 @@ public class RecipeSockColor implements IRecipe {
@Override
public ItemStack getRecipeOutput() {
return null;
}
} */
}

+ 96
- 0
src/main/java/pl/asie/ponysocks/recipe/RecipeBase.java View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe;

import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

import java.util.Collections;
import java.util.List;

public abstract class RecipeBase extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
protected final NonNullList<Ingredient> ingredients = NonNullList.create();
private final String group;
private final boolean shaped;
private final int width, height;

public RecipeBase(ResourceLocation location, String group, boolean shaped, int width, int height) {
this.group = group;
setRegistryName(location);
this.shaped = shaped;
this.width = width;
this.height = height;
}

protected boolean matchesShaped(InventoryCrafting inv) {
for (int iy = 0; iy <= inv.getHeight() - 2; iy++) {
for (int ix = 0; ix <= inv.getWidth() - 3; ix++) {
boolean foundMistake = false;
innerLoop: for (int y = 0; y < 2; y++) {
for (int x = 0; x < 3; x++) {
Ingredient ingredient = ingredients.get(y*3 + x);
if (!ingredient.apply(inv.getStackInRowAndColumn(ix+x, iy+y))) {
foundMistake = true;
break innerLoop;
}
}
}

if (!foundMistake) {
return true;
}
}
}

return false;
}

public boolean isShaped() {
return shaped;
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}

@Override
public String getGroup() {
return group;
}

@Override
public NonNullList<Ingredient> getIngredients() {
return ingredients;
}

@Override
public boolean canFit(int width, int height) {
return shaped ? (width * height) >= (this.width * this.height) : width >= this.width && height >= this.height;
}

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return getRecipeOutput();
}

public List<ItemStack> getRecipeOutputs() {
return Collections.singletonList(getRecipeOutput());
}
}

+ 178
- 0
src/main/java/pl/asie/ponysocks/recipe/RecipeDyeableBase.java View File

@@ -0,0 +1,178 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe;

import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.registries.IForgeRegistryEntry;
import pl.asie.ponysocks.ItemSock;
import pl.asie.ponysocks.PonySocks;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public abstract class RecipeDyeableBase extends RecipeBase {
public static class MixColorResult {
public final boolean found;
public final int valueLeft, valueRight;

public MixColorResult(boolean found, int valueLeft, int valueRight) {
this.found = found;
this.valueLeft = valueLeft;
this.valueRight = valueRight;
}
}

public RecipeDyeableBase(ResourceLocation location, String group, boolean shaped, int width, int height) {
super(location, group, shaped, width, height);
}

protected abstract boolean hasColor(ItemStack stack);
protected abstract int getColor(ItemStack stack);

public static int fromFloats(float[] val) {
return (Math.round(val[0] * 255) << 16) | (Math.round(val[1] * 255) << 8) | Math.round(val[2] * 255);
}

protected MixColorResult mixColor(InventoryCrafting crafting) {
List<Integer> dyeColorsLeft = new ArrayList<Integer>();
List<Integer> dyeColorsRight = new ArrayList<Integer>();
boolean found = false;
int sockX = crafting.getWidth() / 2;
int sockY = crafting.getHeight() / 2;
int fWidth = (int) Math.floor(Math.sqrt(crafting.getSizeInventory()));

int clOut = 0;
int crOut = 0;

for (int i = 0; i < crafting.getSizeInventory(); i++) {
ItemStack s = crafting.getStackInSlot(i);
if (!s.isEmpty() && s.getItem() instanceof ItemSock) {
if (!PonySocks.sock.isColorable(s)) {
return new MixColorResult(false, 0, 0);
}

sockX = i % fWidth;
sockY = i / fWidth;
// if (PonySocks.sock.hasColor(s, false)) dyeColorsLeft.add(PonySocks.sock.getColor(s, false));
// if (PonySocks.sock.hasColor(s, true)) dyeColorsRight.add(PonySocks.sock.getColor(s, true));
clOut = PonySocks.sock.getColor(s, false);
crOut = PonySocks.sock.getColor(s, true);
}
}
for (int i = 0; i < crafting.getSizeInventory(); i++) {
ItemStack s = crafting.getStackInSlot(i);
if (!s.isEmpty() && hasColor(s)) {
int color = getColor(s);
int px = i % fWidth;
int py = i / fWidth;
if (px < sockX || (px == sockX && py < sockY)) {
dyeColorsLeft.add(color);
} else {
dyeColorsRight.add(color);
}
found = true;
}
}

if (!found) {
return new MixColorResult(false, 0, 0);
}

int[] colorLeft = new int[3];
int colorLeftCount = 0;
int colorLeftMax = 0;

int[] colorRight = new int[3];
int colorRightCount = 0;
int colorRightMax = 0;

for (int i: dyeColorsLeft) {
int r = (i >> 16) & 0xFF;
int g = (i >> 8) & 0xFF;
int b = i & 0xFF;
colorLeftMax += Math.max(r, Math.max(g, b));
colorLeft[0] += r;
colorLeft[1] += g;
colorLeft[2] += b;
colorLeftCount++;
}

for (int i: dyeColorsRight) {
int r = (i >> 16) & 0xFF;
int g = (i >> 8) & 0xFF;
int b = i & 0xFF;
colorRightMax += Math.max(r, Math.max(g, b));
colorRight[0] += r;
colorRight[1] += g;
colorRight[2] += b;
colorRightCount++;
}

if (colorLeftCount > 0) {
int rAvgL = colorLeft[0] / colorLeftCount;
int gAvgL = colorLeft[1] / colorLeftCount;
int bAvgL = colorLeft[2] / colorLeftCount;
float var16 = (float) colorLeftMax / (float) colorLeftCount;
float var17 = (float) Math.max(rAvgL, Math.max(gAvgL, bAvgL));
rAvgL = (int) ((float) rAvgL * var16 / var17);
gAvgL = (int) ((float) gAvgL * var16 / var17);
bAvgL = (int) ((float) bAvgL * var16 / var17);
clOut = rAvgL << 16 | gAvgL << 8 | bAvgL;
}

if (colorRightCount > 0) {
int rAvgR = colorRight[0] / colorRightCount;
int gAvgR = colorRight[1] / colorRightCount;
int bAvgR = colorRight[2] / colorRightCount;
float var16 = (float) colorRightMax / (float) colorRightCount;
float var17 = (float) Math.max(rAvgR, Math.max(gAvgR, bAvgR));
rAvgR = (int) ((float) rAvgR * var16 / var17);
gAvgR = (int) ((float) gAvgR * var16 / var17);
bAvgR = (int) ((float) bAvgR * var16 / var17);
crOut = rAvgR << 16 | gAvgR << 8 | bAvgR;
}

return new MixColorResult(true, clOut, crOut);
}


@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
MixColorResult result = mixColor(inv);
if (!result.found) return ItemStack.EMPTY;

ItemStack sock = new ItemStack(PonySocks.sock, 1, 0);
sock.setTagCompound(new NBTTagCompound());
sock.getTagCompound().setInteger("color1", result.valueLeft);
sock.getTagCompound().setInteger("color2", result.valueRight);
return sock;
}

@Override
public ItemStack getRecipeOutput() {
return new ItemStack(PonySocks.sock);
}

@Override
public List<ItemStack> getRecipeOutputs() {
return PonySocks.getSocksShuffled();
}
}

+ 54
- 0
src/main/java/pl/asie/ponysocks/recipe/RecipeSockClear.java View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe;

import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import pl.asie.ponysocks.ItemSock;
import pl.asie.ponysocks.PonySocks;

public class RecipeSockClear extends RecipeBase {
public RecipeSockClear(ResourceLocation location, String group) {
super(location, group, false, 2, 1);
ingredients.add(Ingredient.fromItem(PonySocks.sock));
ingredients.add(Ingredient.fromItem(Items.WATER_BUCKET));
}

@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int countSocks = 0;
int countWaterBuckets = 0;

for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack s = inv.getStackInSlot(i);
if (!s.isEmpty()) {
if (s.getItem() instanceof ItemSock && (!PonySocks.sock.isColorable(s) || PonySocks.sock.hasColor(s, false) || PonySocks.sock.hasColor(s, true))) {
countSocks++;
} else if (s.getItem() == Items.WATER_BUCKET) {
countWaterBuckets++;
} else {
return false;
}
}
}

return countSocks == 1 && countWaterBuckets == 1;
}

@Override
public ItemStack getRecipeOutput() {
return new ItemStack(PonySocks.sock, 1, 0);
}
}

+ 51
- 0
src/main/java/pl/asie/ponysocks/recipe/RecipeSockCreate.java View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe;

import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import pl.asie.ponysocks.PonySocks;

public class RecipeSockCreate extends RecipeDyeableBase {
public RecipeSockCreate(ResourceLocation location, String group) {
super(location, group, true, 3, 2);

ingredients.add(Ingredient.fromItem(Item.getItemFromBlock(Blocks.WOOL)));
ingredients.add(Ingredient.EMPTY);
ingredients.add(Ingredient.fromItem(Item.getItemFromBlock(Blocks.WOOL)));
ingredients.add(Ingredient.fromItem(Item.getItemFromBlock(Blocks.WOOL)));
ingredients.add(Ingredient.EMPTY);
ingredients.add(Ingredient.fromItem(Item.getItemFromBlock(Blocks.WOOL)));
}

@Override
protected boolean hasColor(ItemStack stack) {
return stack.getItem() == Item.getItemFromBlock(Blocks.WOOL);
}

@Override
protected int getColor(ItemStack stack) {
return fromFloats(EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(stack.getMetadata())));
}

@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
return matchesShaped(inv);
}
}

+ 93
- 0
src/main/java/pl/asie/ponysocks/recipe/RecipeSockPaint.java View File

@@ -0,0 +1,93 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe;

import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.commons.lang3.ArrayUtils;
import pl.asie.ponysocks.ItemSock;
import pl.asie.ponysocks.PonySocks;

public class RecipeSockPaint extends RecipeDyeableBase {
public RecipeSockPaint(ResourceLocation location, String group) {
super(location, group, false, 2, 1);

ingredients.add(Ingredient.fromItem(Items.DYE));
ingredients.add(Ingredient.fromItem(PonySocks.sock));
ingredients.add(Ingredient.fromItem(Items.DYE));
}

@Override
protected boolean hasColor(ItemStack stack) {
int[] ids = OreDictionary.getOreIDs(stack);
for (int id : ids) {
if (ArrayUtils.contains(PonySocks.dyeOreIds, id)) {
return true;
}
}

return false;
}

@Override
protected int getColor(ItemStack stack) {
int[] ids = OreDictionary.getOreIDs(stack);
for (int id : ids) {
for (int i = 0; i < 16; i++) {
if (id == PonySocks.dyeOreIds[i]) {
return fromFloats(EntitySheep.getDyeRgb(EnumDyeColor.byDyeDamage(i)));
}
}
}

throw new RuntimeException("Shouldn't happen!");
}

@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int countSocks = 0;
int countDyes = 0;

for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack s = inv.getStackInSlot(i);
if (!s.isEmpty()) {
if (s.getItem() instanceof ItemSock && PonySocks.sock.isColorable(s)) {
countSocks++;
} else if (hasColor(s)) {
countDyes++;
} else {
return false;
}
}
}

if (countSocks == 1 && countDyes > 0) {
for (IRecipe recipe : PonySocks.specialDyeRecipes) {
if (recipe.matches(inv, worldIn)) {
return false;
}
}

return true;
} else {
return false;
}
}
}

+ 53
- 0
src/main/java/pl/asie/ponysocks/recipe/RecipeSockRainbow.java View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe;

import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreIngredient;
import pl.asie.ponysocks.ItemSock;
import pl.asie.ponysocks.PonySocks;

public class RecipeSockRainbow extends RecipeBase {
public RecipeSockRainbow(ResourceLocation location, String group) {
super(location, group, true, 3, 3);

ingredients.add(new OreIngredient("dyeRed"));
ingredients.add(Ingredient.EMPTY);
ingredients.add(new OreIngredient("dyeLime"));

ingredients.add(new OreIngredient("dyeOrange"));
ingredients.add(Ingredient.fromStacks(new ItemStack(PonySocks.sock, 1, 0)));
ingredients.add(new OreIngredient("dyeLightBlue"));

ingredients.add(new OreIngredient("dyeYellow"));
ingredients.add(Ingredient.EMPTY);
ingredients.add(new OreIngredient("dyePurple"));
}

@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
return matchesShaped(inv);
}

@Override
public ItemStack getRecipeOutput() {
ItemStack stack = new ItemStack(PonySocks.sock, 1, 0);
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setInteger("type", 1);
return stack;
}
}

+ 60
- 0
src/main/java/pl/asie/ponysocks/recipe/jei/JEIRecipePony.java View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe.jei;

import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import pl.asie.ponysocks.recipe.RecipeBase;

import java.util.Collections;

public abstract class JEIRecipePony implements IRecipeWrapper {
protected final RecipeBase recipe;

public static class Shapeless extends JEIRecipePony {
public Shapeless(RecipeBase recipe) {
super(recipe);
}
}

public static class Shaped extends JEIRecipePony implements IShapedCraftingRecipeWrapper {
public Shaped(RecipeBase recipe) {
super(recipe);
}

@Override
public int getWidth() {
return recipe.getWidth();
}

@Override
public int getHeight() {
return recipe.getHeight();
}
}

public static JEIRecipePony create(RecipeBase recipe) {
return recipe.isShaped() ? new Shaped(recipe) : new Shapeless(recipe);
}

public JEIRecipePony(RecipeBase recipe) {
this.recipe = recipe;
}

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInputLists(ItemStack.class, PonySocksJEIPlugin.STACKS.expandRecipeItemStackInputs(recipe.getIngredients()));
ingredients.setOutputLists(ItemStack.class, Collections.singletonList(recipe.getRecipeOutputs()));
}
}

+ 44
- 0
src/main/java/pl/asie/ponysocks/recipe/jei/PonySocksJEIPlugin.java View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.recipe.jei;

import mezz.jei.api.*;
import mezz.jei.api.recipe.IStackHelper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import pl.asie.ponysocks.PonySocks;
import pl.asie.ponysocks.recipe.RecipeBase;

import java.util.Collections;

@JEIPlugin
public class PonySocksJEIPlugin implements IModPlugin {
public static IStackHelper STACKS;

@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
subtypeRegistry.useNbtForSubtypes(PonySocks.sock);
}

@Override
public void register(IModRegistry registry) {
STACKS = registry.getJeiHelpers().getStackHelper();

for (IRecipe recipe : ForgeRegistries.RECIPES) {
if (recipe instanceof RecipeBase) {
registry.addRecipes(Collections.singletonList(recipe), VanillaRecipeCategoryUid.CRAFTING);
}
}

registry.handleRecipes(RecipeBase.class, JEIRecipePony::create, VanillaRecipeCategoryUid.CRAFTING);
}
}

+ 17
- 0
src/main/java/pl/asie/ponysocks/render/IStackedArmor.java View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.render;

import net.minecraft.item.ItemStack;

public interface IStackedArmor {
void setArmorStack(ItemStack stack);
}

+ 26
- 0
src/main/java/pl/asie/ponysocks/render/ItemSockColor.java View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.render;

import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.ItemStack;
import pl.asie.ponysocks.PonySocks;

public class ItemSockColor implements IItemColor {
@Override
public int getColorFromItemstack(ItemStack stack, int pass) {
if (stack.getItem() == PonySocks.sock && PonySocks.sock.isColorable(stack)) {
return pass == 2 ? -1 : (0xFF000000 | PonySocks.sock.getColor(stack, pass == 1));
} else {
return -1;
}
}
}

+ 64
- 0
src/main/java/pl/asie/ponysocks/render/ModelArmorSock.java View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.render;

import com.minelittlepony.model.pony.armor.ModelPonyArmor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.Sys;
import pl.asie.ponysocks.PonySocks;

public class ModelArmorSock extends ModelPonyArmor implements IStackedArmor {
private static final ResourceLocation[] LAYERS = new ResourceLocation[] {
new ResourceLocation("ponysocks:textures/models/armor/sock_layer_0_pony.png"),
new ResourceLocation("ponysocks:textures/models/armor/sock_layer_1_pony.png"),
new ResourceLocation("ponysocks:textures/models/armor/sock_rainbow_pony.png")
};

private ItemStack stack;

public ModelArmorSock() {
super();
init(0.0F, 0.025F);
}

public void setArmorStack(ItemStack stack) {
this.stack = stack;
}

@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if (stack.getMetadata() > 0) {
Minecraft.getMinecraft().getTextureManager().bindTexture(LAYERS[Math.min(LAYERS.length - 1, 1 + stack.getMetadata())]);
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
return;
}

for (int i = 0; i < 2; i++) {
int color = PonySocks.sock.getColor(stack, i > 0);
GlStateManager.color(
(float) ((color >> 16) & 0xFF) / 255.0f,
(float) ((color >> 8) & 0xFF) / 255.0f,
(float) (color & 0xFF) / 255.0f,
1.0f
);
Minecraft.getMinecraft().getTextureManager().bindTexture(LAYERS[i]);
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
}
}
}

+ 58
- 0
src/main/java/pl/asie/ponysocks/render/ModelArmorSockBiped.java View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2015, 2017 Adrian Siekierka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package pl.asie.ponysocks.render;

import com.minelittlepony.model.pony.armor.ModelPonyArmor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import pl.asie.ponysocks.PonySocks;

public class ModelArmorSockBiped extends ModelBiped implements IStackedArmor {
private static final ResourceLocation[] LAYERS = new ResourceLocation[] {
new ResourceLocation("ponysocks:textures/models/armor/sock_layer_0.png"),
new ResourceLocation("ponysocks:textures/models/armor/sock_layer_1.png"),
new ResourceLocation("ponysocks:textures/models/armor/sock_rainbow.png")
};
private ItemStack stack;

public ModelArmorSockBiped() {
super(0.025F);
}

public void setArmorStack(ItemStack stack) {
this.stack = stack;
}

@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if (stack.getMetadata() > 0) {
Minecraft.getMinecraft().getTextureManager().bindTexture(LAYERS[Math.min(LAYERS.length - 1, 1 + stack.getMetadata())]);
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
return;
}

for (int i = 0; i < 2; i++) {
int color = PonySocks.sock.getColor(stack, i > 0);
GlStateManager.color(
(float) ((color >> 16) & 0xFF) / 255.0f,
(float) ((color >> 8) & 0xFF) / 255.0f,
(float) (color & 0xFF) / 255.0f,
1.0f
);
Minecraft.getMinecraft().getTextureManager().bindTexture(LAYERS[i]);
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
}
}
}

+ 21
- 0
src/main/resources/assets/ponysocks/blockstates/sockitem.json View File

@@ -0,0 +1,21 @@
{
"forge_marker": 1,
"variants": {
"inventory": {
"model": "forge:item-layer",
"transform": "forge:default-item",
"textures": {
"layer0": "ponysocks:items/icon_sock_layer_0",
"layer1": "ponysocks:items/icon_sock_layer_1",
"layer2": "ponysocks:items/icon_sock_overlay"
}
},
"inventory_rainbow": {
"model": "forge:item-layer",
"transform": "forge:default-item",
"textures": {
"layer0": "ponysocks:items/icon_sock_rainbow"
}
}
}
}

src/main/resources/assets/ponysocks/lang/en_US.lang → src/main/resources/assets/ponysocks/lang/en_us.lang View File


BIN
src/main/resources/assets/ponysocks/textures/armor/sock_layer_fake.png View File


BIN
src/main/resources/assets/ponysocks/textures/items/icon_sock_rainbow.png View File


BIN
src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_0.png View File


src/main/resources/assets/ponysocks/textures/armor/sock_layer_0.png → src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_0_pony.png View File


BIN
src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_1.png View File


src/main/resources/assets/ponysocks/textures/armor/sock_layer_1.png → src/main/resources/assets/ponysocks/textures/models/armor/sock_layer_1_pony.png View File


BIN
src/main/resources/assets/ponysocks/textures/models/armor/sock_rainbow.png View File


BIN
src/main/resources/assets/ponysocks/textures/models/armor/sock_rainbow_pony.png View File


+ 16
- 0
src/main/resources/mcmod.info View File

@@ -0,0 +1,16 @@
[
{
"modid": "ponysocks",
"name": "PonySocks",
"description": "The horsiest fashion mod in all of Ponyville!",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
"authorList": ["asie"],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]

+ 6
- 0
src/main/resources/pack.mcmeta View File

@@ -0,0 +1,6 @@
{
"pack": {
"description": "PonySocks",
"pack_format": 3
}
}

Loading…
Cancel
Save