diff --git a/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java b/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java index 89eee1c5d..85e8a79a5 100644 --- a/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java +++ b/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java @@ -88,7 +88,7 @@ public class JEIIntegrationPlugin implements IModPlugin{ registry.addRecipes(StillRecipeMaker.getStillRecipes()); IRecipeTransferRegistry transferTegistry = registry.getRecipeTransferRegistry(); - transferTegistry.addRecipeTransferHandler(ContainerWorktable.class, VanillaRecipeCategoryUid.CRAFTING, 55, 9, 1, 36); + transferTegistry.addRecipeTransferHandler(ContainerWorktable.class, VanillaRecipeCategoryUid.CRAFTING, 19, 9, 1, 36); } diff --git a/src/main/java/forestry/factory/recipes/jei/centrifuge/CentrifugeRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/centrifuge/CentrifugeRecipeCategory.java index d615468c8..f0eecf0f0 100644 --- a/src/main/java/forestry/factory/recipes/jei/centrifuge/CentrifugeRecipeCategory.java +++ b/src/main/java/forestry/factory/recipes/jei/centrifuge/CentrifugeRecipeCategory.java @@ -35,15 +35,15 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory { private static final int inputSlot = 0; private static final int outputSlot = 1; - private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/squeezersocket.png"); + private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/centrifugesocket.png"); @Nonnull protected final IDrawableAnimated arrow; public CentrifugeRecipeCategory(IGuiHelper guiHelper) { - super(guiHelper.createDrawable(guiTexture, 5, 14, 166, 65), "tile.for.factory.2.name"); + super(guiHelper.createDrawable(guiTexture, 5, 14, 166, 65), "tile.for.factory.2.name", 10); IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 0, 4, 17); - this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false); + this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 80, IDrawableAnimated.StartDirection.BOTTOM, false); } @Nonnull @@ -58,7 +58,7 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory { @Override public void drawAnimations(Minecraft minecraft) { - arrow.draw(minecraft, 53, 25); + arrow.draw(minecraft, 53, 22); } @Override @@ -66,7 +66,7 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory { super.setRecipe(recipeLayout, recipeWrapper); IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); - guiItemStacks.init(inputSlot, true, 25, 26); + guiItemStacks.init(inputSlot, true, 24, 22); guiItemStacks.set(inputSlot, recipeWrapper.getInputs()); CentrifugeRecipeWrapper centrifugeWrapper = (CentrifugeRecipeWrapper) recipeWrapper; setResults(centrifugeWrapper.getRecipe().getAllProducts(), (GuiItemStackGroup) guiItemStacks); @@ -88,12 +88,12 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory { if (i >= OUTPUTS.length) { return; } - int x = 3 + OUTPUTS[i][0] * 18; - int y = 8 + OUTPUTS[i][1] * 18; + int x = 92 + OUTPUTS[i][0] * 18; + int y = 4 + OUTPUTS[i][1] * 18; int ID = outputSlot + i; guiItemStacks.init(ID, false, x, y); guiItemStacks.set(ID, stack.getKey()); - tooltip.addChanceTooltip(ID, stack.getValue()); + tooltip.addChanceTooltip(ID + 1, stack.getValue()); i++; } } diff --git a/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeCategory.java index 91751df0e..bad6c5ffe 100644 --- a/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeCategory.java +++ b/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeCategory.java @@ -35,14 +35,11 @@ public class FabricatorRecipeCategory extends ForestryRecipeCategory { private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/fabricator.png"); @Nonnull private final ICraftingGridHelper craftingGridHelper; - @Nonnull - protected final IDrawable tankOverlay; public FabricatorRecipeCategory(IGuiHelper guiHelper) { - super(guiHelper.createDrawable(guiTexture, 0, 0, 166, 65), "tile.for.factory2.0.name"); + super(guiHelper.createDrawable(guiTexture, 20, 16, 136, 54), "tile.for.factory2.0.name"); craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot, craftOutputSlot); - this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58); } @Nonnull @@ -64,20 +61,20 @@ public class FabricatorRecipeCategory extends ForestryRecipeCategory { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); - guiItemStacks.init(planSlot, true, 134, 6); + guiItemStacks.init(planSlot, true, 118, 0); - guiItemStacks.init(smeltingInputSlot, true, 21, 10); + guiItemStacks.init(smeltingInputSlot, true, 5, 4); - guiItemStacks.init(craftOutputSlot, false, 134, 42); + guiItemStacks.init(craftOutputSlot, false, 118, 36); for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { int index = craftInputSlot + x + (y * 3); - guiItemStacks.init(index, true, 62 + x * 18, 6 + y * 18); + guiItemStacks.init(index, true, 46 + x * 18, y * 18); } } - guiFluidStacks.init(inputTank, true, 21, 37, 16, 16, 10000, false, tankOverlay); + guiFluidStacks.init(inputTank, true, 6, 32, 16, 16, 2000, false, null); FabricatorRecipeWrapper wrapper = (FabricatorRecipeWrapper) recipeWrapper; guiItemStacks.set(planSlot, wrapper.getRecipe().getPlan()); diff --git a/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeHandler.java b/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeHandler.java index 007d54956..16fa0d160 100644 --- a/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeHandler.java +++ b/src/main/java/forestry/factory/recipes/jei/fabricator/FabricatorRecipeHandler.java @@ -32,9 +32,6 @@ public class FabricatorRecipeHandler implements IRecipeHandler fuels = new ArrayList<>(); for (FermenterFuel fuel : FuelManager.fermenterFuel.values()) { fuels.add(fuel.item); } guiItemStacks.set(fuelSlot, fuels); - FermenterRecipeWrapper wrapper = (FermenterRecipeWrapper) recipeWrapper; - guiFluidStacks.set(inputTank, wrapper.getFluidInputs()); guiFluidStacks.set(outputTank, wrapper.getFluidOutputs()); diff --git a/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeMaker.java b/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeMaker.java index bdd0bc3c5..9354f57c8 100644 --- a/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeMaker.java +++ b/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeMaker.java @@ -21,8 +21,9 @@ public class FermenterRecipeMaker { for (ItemStack stack : JEIUtils.getItemVariations(recipe.getResource())) { recipes.add(new FermenterRecipeWrapper(recipe, stack)); } + }else{ + recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource())); } - recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource())); } return recipes; } diff --git a/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeWrapper.java b/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeWrapper.java index d4da9096c..b9c4388fc 100644 --- a/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeWrapper.java +++ b/src/main/java/forestry/factory/recipes/jei/fermenter/FermenterRecipeWrapper.java @@ -1,10 +1,13 @@ package forestry.factory.recipes.jei.fermenter; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.annotation.Nonnull; +import forestry.api.fuels.FermenterFuel; +import forestry.api.fuels.FuelManager; import forestry.api.recipes.IFermenterRecipe; import forestry.api.recipes.IVariableFermentable; import forestry.core.recipes.jei.ForestryRecipeWrapper; @@ -23,7 +26,16 @@ public class FermenterRecipeWrapper extends ForestryRecipeWrapper inputs = new ArrayList<>(); + for (FermenterFuel fuel : FuelManager.fermenterFuel.values()) { + inputs.add(fuel.item); + } + inputs.add(fermentable); + return inputs; + } + + public ItemStack getFermentable() { + return fermentable; } @Override diff --git a/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeCategory.java index e7017b0bf..af14c23ce 100644 --- a/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeCategory.java +++ b/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeCategory.java @@ -34,12 +34,12 @@ public class MoistenerRecipeCategory extends ForestryRecipeCategory { protected final IDrawable tankOverlay; public MoistenerRecipeCategory(IGuiHelper guiHelper) { - super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 61), "tile.for.factory.4.name"); + super(guiHelper.createDrawable(guiTexture, 15, 15, 145, 60), "tile.for.factory.4.name"); IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 91, 29, 55); this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 80, IDrawableAnimated.StartDirection.BOTTOM, false); IDrawableStatic progressBar = guiHelper.createDrawable(guiTexture, 176, 74, 16, 15); - this.progressBar = guiHelper.createAnimatedDrawable(progressBar, 160, IDrawableAnimated.StartDirection.BOTTOM, false); + this.progressBar = guiHelper.createAnimatedDrawable(progressBar, 160, IDrawableAnimated.StartDirection.LEFT, false); this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58); } @@ -55,8 +55,8 @@ public class MoistenerRecipeCategory extends ForestryRecipeCategory { @Override public void drawAnimations(Minecraft minecraft) { - arrow.draw(minecraft, 88, 6); - progressBar.draw(minecraft, 119, 25); + arrow.draw(minecraft, 78, 2); + progressBar.draw(minecraft, 109, 22); } @Override @@ -64,13 +64,13 @@ public class MoistenerRecipeCategory extends ForestryRecipeCategory { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); - guiItemStacks.init(resourceSlot, true, 138, 8); - guiItemStacks.init(fuelItemSlot, true, 34, 47); + guiItemStacks.init(resourceSlot, true, 127, 3); + guiItemStacks.init(fuelItemSlot, true, 23, 42); - guiItemStacks.init(productSlot, false, 138, 44); - guiItemStacks.init(fuelProductSlot, false, 100, 26); + guiItemStacks.init(productSlot, false, 127, 39); + guiItemStacks.init(fuelProductSlot, false, 89, 21); - guiFluidStacks.init(inputTank, true, 11, 5, 16, 58, 10000, false, tankOverlay); + guiFluidStacks.init(inputTank, true, 1, 1, 16, 58, 10000, false, tankOverlay); MoistenerRecipeWrapper wrapper = (MoistenerRecipeWrapper) recipeWrapper; guiItemStacks.set(resourceSlot, wrapper.getRecipe().getResource()); diff --git a/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeWrapper.java b/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeWrapper.java index 499d5555c..71aeafaf9 100644 --- a/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeWrapper.java +++ b/src/main/java/forestry/factory/recipes/jei/moistener/MoistenerRecipeWrapper.java @@ -23,7 +23,7 @@ public class MoistenerRecipeWrapper extends ForestryRecipeWrapper inputs = new ArrayList<>(); - inputs.add(recipe.getProduct()); + inputs.add(recipe.getResource()); if(fuel.item != null) inputs.add(fuel.item); return inputs; diff --git a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerContainerRecipeWrapper.java b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerContainerRecipeWrapper.java index 107d7dc16..89b07b76c 100644 --- a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerContainerRecipeWrapper.java +++ b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerContainerRecipeWrapper.java @@ -10,32 +10,37 @@ import forestry.core.fluids.FluidHelper; import forestry.core.recipes.jei.ForestryRecipeWrapper; import forestry.factory.recipes.ISqueezerContainerRecipe; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; public class SqueezerContainerRecipeWrapper extends ForestryRecipeWrapper{ - public SqueezerContainerRecipeWrapper(@Nonnull ISqueezerContainerRecipe recipe) { + @Nonnull + private ItemStack filledContainer; + + public SqueezerContainerRecipeWrapper(@Nonnull ISqueezerContainerRecipe recipe, @Nonnull ItemStack filledContainer) { super(recipe); + this.filledContainer = filledContainer; } @Override public List getInputs() { - return FluidHelper.getAllFilledContainers(recipe.getEmptyContainer()); + return Collections.singletonList(filledContainer); } @Override public List getFluidOutputs() { - List fluids = new ArrayList<>(); - for (ItemStack ingredient : FluidHelper.getAllFilledContainers(recipe.getEmptyContainer())) { - FluidStack fluidStack = FluidHelper.getFluidStackInContainer(ingredient); - fluids.add(fluidStack); - } - return fluids; + return Collections.singletonList(FluidContainerRegistry.getFluidForFilledItem(filledContainer)); } @Override public List getOutputs() { return Collections.singletonList(recipe.getRemnants()); } + + @Override + public boolean equals(Object obj) { + return super.equals(obj); + } } diff --git a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeCategory.java index b8afdc0e9..ae9773b1f 100644 --- a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeCategory.java +++ b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeCategory.java @@ -1,5 +1,6 @@ package forestry.factory.recipes.jei.squeezer; +import java.util.Collection; import java.util.List; import javax.annotation.Nonnull; @@ -32,8 +33,6 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory { private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/squeezersocket.png"); @Nonnull - private final ICraftingGridHelper craftingGridHelper; - @Nonnull protected final IDrawableAnimated arrow; @Nonnull protected final IDrawable tankOverlay; @@ -41,12 +40,11 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory { protected final String UID; public SqueezerRecipeCategory(IGuiHelper guiHelper, String UID) { - super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 61), "tile.for.factory.5.name"); + super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 61), "tile.for.factory.5.name", 10); - craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot, craftOutputSlot); - IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 59, 4, 17); - this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.BOTTOM, false); - this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 60, 43, 18); + IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 60, 43, 18); + this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false); + this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58); this.UID = UID; } @@ -62,7 +60,7 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory { @Override public void drawAnimations(Minecraft minecraft) { - arrow.draw(minecraft, 70, 30); + arrow.draw(minecraft, 67, 25); } @Override @@ -80,25 +78,29 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory { chance = ((ISqueezerContainerRecipe) wrapper.getRecipe()).getRemnantsChance(); } - guiFluidStacks.init(outputTank, false, 117, 7, 16, 58, 10000, false, tankOverlay); + guiFluidStacks.init(outputTank, false, 113, 2, 16, 58, 10000, false, tankOverlay); guiFluidStacks.set(outputTank, recipeWrapper.getFluidOutputs()); - guiItemStacks.init(craftOutputSlot, false, 92, 49); - craftingGridHelper.setOutput(guiItemStacks, recipeWrapper.getOutputs()); + guiItemStacks.init(craftOutputSlot, false, 87, 43); + guiItemStacks.set(craftOutputSlot, recipeWrapper.getOutputs()); + tooltip.addChanceTooltip(craftOutputSlot, chance); setIngredients(guiItemStacks, recipeWrapper.getInputs(), chance); guiItemStacks.addTooltipCallback(tooltip); } - public void setIngredients(IGuiItemStackGroup guiItemStacks, List inputs, float chance) { + public void setIngredients(IGuiItemStackGroup guiItemStacks, List inputs, float chance) { int i = 0; - for (ItemStack stack : inputs) { - guiItemStacks.init(craftInputSlot + i, true, 12 + INPUTS[i][0] * 18, 10 + INPUTS[i][1] * 18); - tooltip.addChanceTooltip(i, chance); + for (Object stack : inputs) { + guiItemStacks.init(craftInputSlot + i, true, 7 + INPUTS[i][0] * 18, 4 + INPUTS[i][1] * 18); + if(stack instanceof ItemStack){ + guiItemStacks.set(craftInputSlot + i, (ItemStack) stack); + }else{ + guiItemStacks.set(craftInputSlot + i, (Collection) stack); + } i++; } - craftingGridHelper.setInput(guiItemStacks, inputs); } } diff --git a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeMaker.java b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeMaker.java index 3ff63fae1..bf3ef5d71 100644 --- a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeMaker.java +++ b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeMaker.java @@ -5,9 +5,14 @@ import java.util.List; import forestry.api.recipes.ISqueezerRecipe; import forestry.api.recipes.RecipeManagers; +import forestry.core.fluids.FluidHelper; import forestry.factory.recipes.ISqueezerContainerRecipe; import forestry.factory.recipes.SqueezerRecipeManager; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; public class SqueezerRecipeMaker { @@ -28,7 +33,7 @@ public class SqueezerRecipeMaker { for(FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()){ ISqueezerContainerRecipe containerRecipe = SqueezerRecipeManager.findMatchingContainerRecipe(data.filledContainer); if (containerRecipe != null) { - recipes.add(new SqueezerContainerRecipeWrapper(containerRecipe)); + recipes.add(new SqueezerContainerRecipeWrapper(containerRecipe, data.filledContainer)); } } return recipes; diff --git a/src/main/java/forestry/factory/recipes/jei/still/StillRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/still/StillRecipeCategory.java index f828d7ad5..8c7767bdb 100644 --- a/src/main/java/forestry/factory/recipes/jei/still/StillRecipeCategory.java +++ b/src/main/java/forestry/factory/recipes/jei/still/StillRecipeCategory.java @@ -6,6 +6,8 @@ import forestry.core.recipes.jei.ForestryRecipeCategory; import forestry.core.recipes.jei.ForestryRecipeCategoryUid; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IDrawableAnimated; +import mezz.jei.api.gui.IDrawableStatic; import mezz.jei.api.gui.IGuiFluidStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.IRecipeWrapper; @@ -21,10 +23,15 @@ public class StillRecipeCategory extends ForestryRecipeCategory { @Nonnull protected final IDrawable tankOverlay; + @Nonnull + protected final IDrawableAnimated progressBar; public StillRecipeCategory(IGuiHelper guiHelper) { super(guiHelper.createDrawable(guiTexture, 30, 11, 116, 65), "tile.for.factory.6.name"); this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58); + + IDrawableStatic progressBarDrawable0 = guiHelper.createDrawable(guiTexture, 176, 74, 4, 18); + this.progressBar = guiHelper.createAnimatedDrawable(progressBarDrawable0, 20, IDrawableAnimated.StartDirection.BOTTOM, false); } @Override @@ -38,6 +45,7 @@ public class StillRecipeCategory extends ForestryRecipeCategory { @Override public void drawAnimations(Minecraft minecraft) { + progressBar.draw(minecraft, 54, 6); } @Override @@ -45,8 +53,8 @@ public class StillRecipeCategory extends ForestryRecipeCategory { IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); - guiFluidStacks.init(inputTank, true, 30, 4, 16, 58, 10000, false, tankOverlay); - guiFluidStacks.init(outputTank, false, 120, 4, 16, 58, 10000, false, tankOverlay); + guiFluidStacks.init(inputTank, true, 5, 4, 16, 58, 10000, false, tankOverlay); + guiFluidStacks.init(outputTank, false, 95, 4, 16, 58, 10000, false, tankOverlay); guiFluidStacks.set(inputTank, recipeWrapper.getFluidInputs()); guiFluidStacks.set(outputTank, recipeWrapper.getFluidOutputs()); diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index c87c8d696..13b2ddcc4 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -148,7 +148,7 @@ public class ItemBeverage extends ItemForestryFood { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j == 0 || beverages[itemstack.getItemDamage()].getSecondaryColor() == 0) { + if (j == 1 || beverages[itemstack.getItemDamage()].getSecondaryColor() == 0) { return beverages[itemstack.getItemDamage()].getPrimaryColor(); } else { return beverages[itemstack.getItemDamage()].getSecondaryColor(); diff --git a/src/main/java/net/minecraftforge/debug/DynBucketTest.java b/src/main/java/net/minecraftforge/debug/DynBucketTest.java deleted file mode 100644 index cfa812818..000000000 --- a/src/main/java/net/minecraftforge/debug/DynBucketTest.java +++ /dev/null @@ -1,177 +0,0 @@ -package net.minecraftforge.debug; - -import java.util.List; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.ItemMeshDefinition; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.debug.ModelFluidDebug.TestFluid; -import net.minecraftforge.debug.ModelFluidDebug.TestGas; -import net.minecraftforge.event.entity.player.FillBucketEvent; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidBlock; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -@Mod(modid = "DynBucketTest", version = "0.1", dependencies = "after:" + ModelFluidDebug.MODID) -public class DynBucketTest -{ - public static final Item dynBucket = new DynBucket(); - public static final Item dynBottle = new DynBottle(); - - @SidedProxy - public static CommonProxy proxy; - - public static class CommonProxy - { - void setupModels() - { - } - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - @Override - void setupModels() - { - ModelLoader.setBucketModelDefinition(dynBucket); - - final ModelResourceLocation bottle = new ModelResourceLocation(new ResourceLocation("forge", "dynbottle"), "inventory"); - ModelLoader.setCustomMeshDefinition(dynBottle, new ItemMeshDefinition() - { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - return bottle; - } - }); - ModelBakery.registerItemVariants(dynBottle, bottle); - } - } - - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerItem(dynBucket, "dynbucket"); - GameRegistry.registerItem(dynBottle, "dynbottle"); - - // register fluid containers - int i = 0; - //registerFluidContainer(FluidRegistry.WATER, i++); - //registerFluidContainer(FluidRegistry.LAVA, i++); - registerFluidContainer(FluidRegistry.getFluid(TestFluid.name), i++); - registerFluidContainer(FluidRegistry.getFluid(TestGas.name), i++); - - i = 0; - registerFluidContainer2(FluidRegistry.WATER, i++); - registerFluidContainer2(FluidRegistry.LAVA, i++); - registerFluidContainer2(FluidRegistry.getFluid(TestFluid.name), i++); - registerFluidContainer2(FluidRegistry.getFluid(TestGas.name), i++); - - // Set TestFluidBlocks blockstate to use milk instead of testfluid for the texture to be loaded - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid("milk"), new ItemStack(Items.milk_bucket), FluidContainerRegistry.EMPTY_BUCKET); - - proxy.setupModels(); - MinecraftForge.EVENT_BUS.register(this); - } - - private void registerFluidContainer(Fluid fluid, int meta) - { - if (fluid == null) - return; - - FluidStack fs = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME); - ItemStack stack = new ItemStack(dynBucket, 1, meta); - FluidContainerRegistry.registerFluidContainer(fs, stack, new ItemStack(Items.bucket)); - } - - private void registerFluidContainer2(Fluid fluid, int meta) - { - if (fluid == null) - return; - - FluidStack fs = new FluidStack(fluid, 250); - ItemStack stack = new ItemStack(dynBottle, 1, meta); - FluidContainerRegistry.registerFluidContainer(fs, stack, new ItemStack(Items.glass_bottle)); - } - - @SubscribeEvent - public void onBucketFill(FillBucketEvent event) - { - IBlockState state = event.world.getBlockState(event.target.getBlockPos()); - if (state.getBlock() instanceof IFluidBlock) - { - Fluid fluid = ((IFluidBlock) state.getBlock()).getFluid(); - FluidStack fs = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME); - - ItemStack filled = FluidContainerRegistry.fillFluidContainer(fs, event.current); - if (filled != null) - { - event.result = filled; - event.setResult(Result.ALLOW); - } - } - } - - public static class DynBucket extends Item - { - public DynBucket() - { - setUnlocalizedName("dynbucket"); - setMaxStackSize(1); - setHasSubtypes(true); - setCreativeTab(CreativeTabs.tabMisc); - } - - @Override - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) - { - for (int i = 0; i < 4; i++) - { - ItemStack bucket = new ItemStack(this, 1, i); - if (FluidContainerRegistry.isFilledContainer(bucket)) - subItems.add(bucket); - } - } - } - - public static class DynBottle extends Item - { - public DynBottle() - { - setUnlocalizedName("dynbottle"); - setMaxStackSize(1); - setHasSubtypes(true); - setCreativeTab(CreativeTabs.tabMisc); - } - - @Override - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) - { - for (int i = 0; i < 4; i++) - { - ItemStack bucket = new ItemStack(this, 1, i); - if (FluidContainerRegistry.isFilledContainer(bucket)) - subItems.add(bucket); - } - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/EnumPlantTypeTest.java b/src/main/java/net/minecraftforge/debug/EnumPlantTypeTest.java deleted file mode 100644 index 2f7e7aa86..000000000 --- a/src/main/java/net/minecraftforge/debug/EnumPlantTypeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraftforge.common.BiomeManager.BiomeType; -import net.minecraftforge.common.EnumPlantType; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -@Mod(modid = "enumplanttypetest") -public class EnumPlantTypeTest -{ - private static Logger LOGGER = LogManager.getLogger(); - - @Mod.EventHandler - public void onInit(FMLInitializationEvent event) - { - BiomeType biomeType = null; - try - { - biomeType = BiomeType.getType("FAKE"); - } - catch (NullPointerException npe) - { - LOGGER.warn("EnumHelper in BiomeType is working incorrectly!", npe); - } - finally - { - if (biomeType == null || !biomeType.name().equals("FAKE")) - LOGGER.warn("EnumHelper in BiomeType is working incorrectly!"); - } - EnumPlantType plantType = null; - if (plantType == null || !plantType.name().equals("FAKE")) - ; - try - { - plantType = EnumPlantType.getPlantType("FAKE"); - } - catch (NullPointerException npe) - { - LOGGER.warn("EnumHelper in EnumPlantType is working incorrectly!", npe); - } - finally - { - if (plantType == null || !plantType.name().equals("FAKE")) - LOGGER.warn("EnumHelper in EnumPlantType is working incorrectly!"); - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java b/src/main/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java deleted file mode 100644 index 271b392af..000000000 --- a/src/main/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java +++ /dev/null @@ -1,132 +0,0 @@ -package net.minecraftforge.debug; - -import java.util.Map; -import java.util.Map.Entry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockWall; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockState; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.statemap.IStateMapper; -import net.minecraft.client.renderer.block.statemap.StateMap; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemMultiTexture; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IStringSerializable; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameData; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import com.google.common.base.Function; -import com.google.common.collect.Maps; - -@Mod(modid = ForgeBlockStatesLoaderDebug.MODID) -public class ForgeBlockStatesLoaderDebug { - public static final String MODID = "ForgeBlockStatesLoader"; - public static final String ASSETS = "forgeblockstatesloader:"; - - public static final Block blockCustom = new CustomMappedBlock(); - public static final String nameCustomWall = "custom_wall"; - public static final BlockWall blockCustomWall = new BlockWall(Blocks.cobblestone); - public static final ItemMultiTexture itemCustomWall = (ItemMultiTexture)new ItemMultiTexture(blockCustomWall, blockCustomWall, new Function() - { - @Override - public String apply(ItemStack stack) - { - return BlockWall.EnumType.byMetadata(stack.getMetadata()).getUnlocalizedName(); - } - }).setRegistryName(nameCustomWall); - - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - blockCustom.setUnlocalizedName(MODID + ".customBlock").setRegistryName("customBlock"); - GameRegistry.registerBlock(blockCustom); - - blockCustomWall.setUnlocalizedName(MODID + ".customWall").setRegistryName(nameCustomWall); - GameRegistry.registerBlock(blockCustomWall, (Class)null); - GameRegistry.registerItem(itemCustomWall); - GameData.getBlockItemMap().put(blockCustomWall, itemCustomWall); - - if (event.getSide() == Side.CLIENT) - preInitClient(event); - } - - @SideOnly(Side.CLIENT) - public void preInitClient(FMLPreInitializationEvent event) - { - ModelLoader.setCustomStateMapper(blockCustom, new StateMap.Builder().withName(CustomMappedBlock.VARIANT).build()); - - ModelLoader.setCustomStateMapper(blockCustomWall, new IStateMapper() - { - StateMap stateMap = new StateMap.Builder().withName(BlockWall.VARIANT).withSuffix("_wall").build(); - @Override - public Map putStateModelLocations(Block block) - { - Map map = stateMap.putStateModelLocations(block); - Map newMap = Maps.newHashMap(); - - for (Entry e : map.entrySet()) - { - ModelResourceLocation loc = e.getValue(); - newMap.put(e.getKey(), new ModelResourceLocation(ASSETS + loc.getResourcePath(), loc.getVariant())); - } - - return newMap; - } - }); - Item customWallItem = Item.getItemFromBlock(blockCustomWall); - ModelLoader.setCustomModelResourceLocation(customWallItem, 0, new ModelResourceLocation(ASSETS + "cobblestone_wall", "inventory")); - ModelLoader.setCustomModelResourceLocation(customWallItem, 1, new ModelResourceLocation(ASSETS + "mossy_cobblestone_wall", "inventory")); - } - - // this block is never actually used, it's only needed for the error message on load to see the variant it maps to - public static class CustomMappedBlock extends Block - { - public static final PropertyEnum VARIANT = PropertyEnum.create("type", CustomVariant.class); - - protected CustomMappedBlock() { - super(Material.rock); - - this.setUnlocalizedName(MODID + ".customMappedBlock"); - } - - @Override - protected BlockState createBlockState() { - return new BlockState(this, VARIANT); - } - - @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(VARIANT).ordinal(); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - if(meta > CustomVariant.values().length || meta < 0) - meta = 0; - - return this.getDefaultState().withProperty(VARIANT, CustomVariant.values()[meta]); - } - - public static enum CustomVariant implements IStringSerializable { - TypeA, - TypeB; - - @Override - public String getName() { return this.toString(); }; - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/ItemLayerModelDebug.java b/src/main/java/net/minecraftforge/debug/ItemLayerModelDebug.java deleted file mode 100644 index da52b7f66..000000000 --- a/src/main/java/net/minecraftforge/debug/ItemLayerModelDebug.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraftforge.client.model.ModelLoader; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -@Mod(modid = ItemLayerModelDebug.MODID, version = ItemLayerModelDebug.VERSION) -public class ItemLayerModelDebug -{ - public static final String MODID = "ForgeDebugItemLayerModel"; - public static final String VERSION = "1.0"; - - @SidedProxy - public static CommonProxy proxy; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } - - public static class CommonProxy - { - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerItem(TestItem.instance, TestItem.name); - } - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - private static ModelResourceLocation modelLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestItem.name, "inventory"); - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - ModelLoader.setCustomModelResourceLocation(TestItem.instance, 0, modelLocation); - } - } - - public static final class TestItem extends Item - { - public static final TestItem instance = new TestItem(); - public static final String name = "TestItem"; - - private TestItem() - { - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/ItemTileDebug.java b/src/main/java/net/minecraftforge/debug/ItemTileDebug.java deleted file mode 100644 index 6a21bba96..000000000 --- a/src/main/java/net/minecraftforge/debug/ItemTileDebug.java +++ /dev/null @@ -1,144 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.registry.ClientRegistry; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; -import static org.lwjgl.opengl.GL11.*; - -@Mod(modid = ItemTileDebug.MODID) -public class ItemTileDebug -{ - public static final String MODID = "ForgeDebugItemTile"; - - private static String blockName = MODID.toLowerCase() + ":" + TestBlock.name; - - @SidedProxy - public static CommonProxy proxy; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } - - @EventHandler - public void init(FMLInitializationEvent event) { proxy.init(event); } - - public static class CommonProxy - { - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerBlock(TestBlock.instance, TestBlock.name); - GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity"); - } - - public void init(FMLInitializationEvent event) {} - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "inventory"); - - @SuppressWarnings("deprecation") - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - Item item = Item.getItemFromBlock(TestBlock.instance); - ForgeHooksClient.registerTESRItemStack(item, 0, CustomTileEntity.class); - ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation); - MinecraftForge.EVENT_BUS.register(BakeEventHandler.instance); - } - - @Override - public void init(FMLInitializationEvent event) { - ClientRegistry.bindTileEntitySpecialRenderer(CustomTileEntity.class, TestTESR.instance); - } - } - - public static class BakeEventHandler - { - public static final BakeEventHandler instance = new BakeEventHandler(); - - private BakeEventHandler() {}; - - @SubscribeEvent - public void onModelBakeEvent(ModelBakeEvent event) - { - event.modelManager.getBlockModelShapes().registerBuiltInBlocks(TestBlock.instance); - } - } - - public static class TestTESR extends TileEntitySpecialRenderer - { - private static final TestTESR instance = new TestTESR(); - - private TestTESR() {} - - @Override - public void renderTileEntityAt(CustomTileEntity p_180535_1_, double x, double y, double z, float p_180535_8_, int p_180535_9_) - { - glPushMatrix(); - glTranslated(x, y, z); - GlStateManager.disableTexture2D(); - GlStateManager.disableLighting(); - glColor4f(.2f, 1, .1f, 1); - glBegin(GL_QUADS); - glVertex3f(0, .5f, 0); - glVertex3f(0, .5f, 1); - glVertex3f(1, .5f, 1); - glVertex3f(1, .5f, 0); - glEnd(); - glPopMatrix(); - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - } - } - - public static class TestBlock extends BlockContainer - { - public static final TestBlock instance = new TestBlock(); - public static final String name = "custom_model_block"; - - private TestBlock() - { - super(Material.iron); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return new CustomTileEntity(); - } - } - - public static class CustomTileEntity extends TileEntity {} -} diff --git a/src/main/java/net/minecraftforge/debug/LayerBreakingTest.java b/src/main/java/net/minecraftforge/debug/LayerBreakingTest.java deleted file mode 100644 index 05cdf8a24..000000000 --- a/src/main/java/net/minecraftforge/debug/LayerBreakingTest.java +++ /dev/null @@ -1,226 +0,0 @@ - -package net.minecraftforge.debug; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelShapes; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.model.IFlexibleBakedModel; -import net.minecraftforge.client.model.ISmartBlockModel; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.relauncher.Side; - -import com.google.common.primitives.Ints; - -@SuppressWarnings( "deprecation" ) -@Mod( modid = "LayerBreakingTest", name = "LayerBreakingTest", version = "0.0.0" ) -public class LayerBreakingTest -{ - public static final boolean ENABLE = true; - public static TestBlock testBlock; - - class TestBakedModel implements IFlexibleBakedModel - { - TextureAtlasSprite texture; - List list = new ArrayList(); - - private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, int u, int v) - { - return new int[] { Float.floatToRawIntBits(x), Float.floatToRawIntBits(y), Float.floatToRawIntBits(z), color, Float.floatToRawIntBits(texture.getInterpolatedU(u)), Float.floatToRawIntBits(texture.getInterpolatedV(v)), 0 }; - } - - public TestBakedModel(TextureAtlasSprite sprite, boolean top) - { - texture = sprite; - if (top) - { - list.add(new BakedQuad(Ints.concat(vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(1, 1.0f, 1, -1, texture, 16, 16), vertexToInts(1, 1.0f, 0, -1, texture, 16, 0)), -1, EnumFacing.UP)); - } - else - { - list.add(new BakedQuad(Ints.concat(vertexToInts(0, 1.0f, 0, -1, texture, 0, 0), vertexToInts(0, 1.0f, 1, -1, texture, 0, 16), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0)), -1, EnumFacing.DOWN)); - } - } - - @Override - public boolean isAmbientOcclusion() - { - return true; - } - - @Override - public boolean isGui3d() - { - return true; - } - - @Override - public boolean isBuiltInRenderer() - { - return false; - } - - @Override - public TextureAtlasSprite getParticleTexture() - { - return texture; - } - - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } - - @Override - public List getFaceQuads(EnumFacing side) - { - return Collections.emptyList(); - } - - @Override - public List getGeneralQuads() - { - return list; - } - - @Override - public VertexFormat getFormat() - { - return null; - } - }; - - class TestBlock extends Block - { - protected TestBlock() - { - super(Material.glass); - setHardness(7); - setCreativeTab(CreativeTabs.tabBlock); - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean isFullCube() - { - return false; - } - - @Override - public boolean canRenderInLayer(EnumWorldBlockLayer layer) - { - return layer == EnumWorldBlockLayer.SOLID || layer == EnumWorldBlockLayer.TRANSLUCENT; - } - }; - - class SmartModel implements IBakedModel, ISmartBlockModel - { - IFlexibleBakedModel solid; - IFlexibleBakedModel translucent; - - @Override - public List getFaceQuads(EnumFacing p_177551_1_) - { - return Collections.emptyList(); - } - - @Override - public List getGeneralQuads() - { - return Collections.emptyList(); - } - - @Override - public boolean isAmbientOcclusion() - { - return true; - } - - @Override - public boolean isGui3d() - { - return true; - } - - @Override - public boolean isBuiltInRenderer() - { - return false; - } - - @Override - public TextureAtlasSprite getParticleTexture() - { - return null; - } - - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } - - @Override - public IBakedModel handleBlockState(IBlockState state) - { - if (solid == null) - { - BlockModelShapes models = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); - translucent = new TestBakedModel(models.getModelForState(Blocks.stained_glass.getStateFromMeta(3)).getParticleTexture(), true); - solid = new TestBakedModel(models.getModelForState(Blocks.cobblestone.getDefaultState()).getParticleTexture(), false); - } - - if (net.minecraftforge.client.MinecraftForgeClient.getRenderLayer() == EnumWorldBlockLayer.SOLID) - { - return solid; - } - else - { - return translucent; - } - } - }; - - @SubscribeEvent - public void onModelBakeEvent(ModelBakeEvent event) - { - event.modelRegistry.putObject(new ModelResourceLocation("layerbreakingtest:layer_breaking_test"), new SmartModel()); - } - - @EventHandler - public void init(FMLInitializationEvent event) - { - if (ENABLE && event.getSide() == Side.CLIENT) - { - MinecraftForge.EVENT_BUS.register(this); - GameRegistry.registerBlock(testBlock = new TestBlock(), "layer_breaking_test"); - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/ModelAnimationDebug.java b/src/main/java/net/minecraftforge/debug/ModelAnimationDebug.java deleted file mode 100644 index 4ba5d9f46..000000000 --- a/src/main/java/net/minecraftforge/debug/ModelAnimationDebug.java +++ /dev/null @@ -1,295 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockPistonBase; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ITickable; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.client.model.ISmartBlockModel; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.b3d.B3DLoader; -import net.minecraftforge.client.model.b3d.B3DLoader.B3DFrameProperty; -import net.minecraftforge.client.model.b3d.B3DLoader.B3DState; -import net.minecraftforge.common.property.ExtendedBlockState; -import net.minecraftforge.common.property.IExtendedBlockState; -import net.minecraftforge.common.property.IUnlistedProperty; -import net.minecraftforge.fml.client.registry.ClientRegistry; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -import org.lwjgl.opengl.GL11; - -@Mod(modid = ModelAnimationDebug.MODID, version = ModelAnimationDebug.VERSION) -public class ModelAnimationDebug -{ - public static final String MODID = "forgedebugmodelanimation"; - public static final String VERSION = "0.0"; - - public static String blockName = "test_animation_block"; - public static final PropertyDirection FACING = PropertyDirection.create("facing"); - public static final PropertyBool STATIC = PropertyBool.create("static");; - - @SidedProxy - public static CommonProxy proxy; - - public static class CommonProxy - { - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerBlock(new Block(Material.wood) - { - { - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + "." + blockName); - } - - @Override - public ExtendedBlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[]{ FACING, STATIC }, new IUnlistedProperty[]{ B3DFrameProperty.instance }); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) - { - return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(world, pos, placer)); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(FACING).getIndex(); - } - - @Override - public boolean hasTileEntity(IBlockState state) { - return true; - } - - @Override - public TileEntity createTileEntity(World world, IBlockState state) { - return new Chest(state); - } - - @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { - return state.withProperty(STATIC, true); - } - - /*@Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity te = world.getTileEntity(pos); - if(te instanceof Chest && state instanceof IExtendedBlockState) - { - return ((Chest)te).getState((IExtendedBlockState)state); - } - return super.getExtendedState(state, world, pos); - }*/ - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) - { - if(world.isRemote) - { - TileEntity te = world.getTileEntity(pos); - if(te instanceof Chest) - { - ((Chest)te).click(); - } - } - return false; - } - }, blockName); - } - - public void init(FMLInitializationEvent event) {} - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - B3DLoader.instance.addDomain(MODID); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GameRegistry.findBlock(MODID, blockName)), 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + blockName, "inventory")); - ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, ChestRenderer.instance); - } - - @Override - public void init(FMLInitializationEvent event) - { - super.init(event); - } - } - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } - - @EventHandler - public void init(FMLInitializationEvent event) { proxy.init(event); } - - private static class Chest extends TileEntity implements ITickable - { - private final int minFrame = 1; - private final int maxFrame = 10; - private int tick = minFrame; - private boolean opening = false; - private boolean closing = false; - - public Chest(IBlockState state) { - } - - /*public IExtendedBlockState getState(IExtendedBlockState state) { - return state.withProperty(B3DFrameProperty.instance, curState); - }*/ - - public void click() - { - if(opening || tick == maxFrame) - { - opening = false; - closing = true; - return; - } - if(closing || tick == minFrame) - { - closing = false; - opening = true; - return; - } - opening = true; - } - - @Override - public void update() - { - if(opening) - { - tick++; - if(tick >= maxFrame) - { - tick = maxFrame; - opening = false; - } - } - if(closing) - { - tick--; - if(tick <= minFrame) - { - tick = minFrame; - closing = false; - } - } - } - - public int getCurFrame() - { - return tick; - } - - public int getNextFrame() - { - if(opening) return Math.min(tick + 1, maxFrame); - if(closing) return Math.max(tick - 1, minFrame); - return tick; - } - } - - private static class ChestRenderer extends TileEntitySpecialRenderer - { - public static ChestRenderer instance = new ChestRenderer(); - private ChestRenderer() {} - - private BlockRendererDispatcher blockRenderer; - - @Override - public void renderTileEntityAt(Chest te, double x, double y, double z, float partialTick, int breakStage) - { - if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); - IBlockState state = te.getWorld().getBlockState(te.getPos()); - state = state.withProperty(STATIC, false); - IBakedModel model = this.blockRenderer.getBlockModelShapes().getModelForState(state); - if(state instanceof IExtendedBlockState) - { - IExtendedBlockState exState = (IExtendedBlockState)state; - if(exState.getUnlistedNames().contains(B3DFrameProperty.instance)) - { - exState = exState.withProperty(B3DFrameProperty.instance, new B3DState(null, te.getCurFrame(), te.getNextFrame(), partialTick)); - if(model instanceof ISmartBlockModel) - { - model = ((ISmartBlockModel)model).handleBlockState(exState); - } - } - } - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - this.bindTexture(TextureMap.locationBlocksTexture); - RenderHelper.disableStandardItemLighting(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableBlend(); - GlStateManager.disableCull(); - - if (Minecraft.isAmbientOcclusionEnabled()) - { - GlStateManager.shadeModel(GL11.GL_SMOOTH); - } - else - { - GlStateManager.shadeModel(GL11.GL_FLAT); - } - - worldrenderer.begin(7, DefaultVertexFormats.BLOCK); - worldrenderer.setTranslation(x - te.getPos().getX(), y - te.getPos().getY(), z - te.getPos().getZ()); - - this.blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, te.getPos(), worldrenderer, false); - - worldrenderer.setTranslation(0, 0, 0); - tessellator.draw(); - - RenderHelper.enableStandardItemLighting(); - } - } -} - diff --git a/src/main/java/net/minecraftforge/debug/ModelBakeEventDebug.java b/src/main/java/net/minecraftforge/debug/ModelBakeEventDebug.java deleted file mode 100644 index 515115bc3..000000000 --- a/src/main/java/net/minecraftforge/debug/ModelBakeEventDebug.java +++ /dev/null @@ -1,348 +0,0 @@ -package net.minecraftforge.debug; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockState; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.statemap.StateMapperBase; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.model.ISmartBlockModel; -import net.minecraftforge.client.model.ISmartItemModel; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.property.ExtendedBlockState; -import net.minecraftforge.common.property.IExtendedBlockState; -import net.minecraftforge.common.property.IUnlistedProperty; -import net.minecraftforge.common.property.Properties; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -import com.google.common.primitives.Ints; - -@SuppressWarnings("deprecation") -@Mod(modid = ModelBakeEventDebug.MODID, version = ModelBakeEventDebug.VERSION) -public class ModelBakeEventDebug -{ - public static final String MODID = "ForgeDebugModelBakeEvent"; - public static final String VERSION = "1.0"; - public static final int cubeSize = 3; - - private static String blockName = MODID.toLowerCase() + ":" + CustomModelBlock.name; - - @SuppressWarnings("unchecked") - public static final IUnlistedProperty[] properties = new IUnlistedProperty[6]; - - static - { - for(EnumFacing f : EnumFacing.values()) - { - properties[f.ordinal()] = Properties.toUnlisted(PropertyInteger.create(f.getName(), 0, (1 << (cubeSize * cubeSize)) - 1)); - } - } - - @SidedProxy - public static CommonProxy proxy; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } - - public static class CommonProxy - { - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerBlock(CustomModelBlock.instance, CustomModelBlock.name); - GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity"); - } - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - private static ModelResourceLocation blockLocation = new ModelResourceLocation(blockName, "normal"); - private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "inventory"); - - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - Item item = Item.getItemFromBlock(CustomModelBlock.instance); - ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation); - ModelLoader.setCustomStateMapper(CustomModelBlock.instance, new StateMapperBase(){ - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_) - { - return blockLocation; - } - }); - MinecraftForge.EVENT_BUS.register(BakeEventHandler.instance); - } - } - - public static class BakeEventHandler - { - public static final BakeEventHandler instance = new BakeEventHandler(); - - private BakeEventHandler() {}; - - @SubscribeEvent - public void onModelBakeEvent(ModelBakeEvent event) - { - TextureAtlasSprite base = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/slime"); - TextureAtlasSprite overlay = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/redstone_block"); - IBakedModel customModel = new CustomModel(base, overlay); - event.modelRegistry.putObject(ClientProxy.blockLocation, customModel); - event.modelRegistry.putObject(ClientProxy.itemLocation, customModel); - } - } - - public static class CustomModelBlock extends BlockContainer - { - public static final CustomModelBlock instance = new CustomModelBlock(); - public static final String name = "custom_model_block"; - - private CustomModelBlock() - { - super(Material.iron); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public int getRenderType() { return 3; } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return new CustomTileEntity(); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) - { - TileEntity te = world.getTileEntity(pos); - if(te instanceof CustomTileEntity) - { - CustomTileEntity cte = (CustomTileEntity) te; - Vec3 vec = revRotate(new Vec3(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5); - IUnlistedProperty property = properties[side.ordinal()]; - Integer value = cte.getState().getValue(property); - if(value == null) value = 0; - value ^= (1 << ( cubeSize * ((int)(vec.xCoord * (cubeSize - .0001))) + ((int)(vec.zCoord * (cubeSize - .0001))) )); - cte.setState(cte.getState().withProperty(property, value)); - world.markBlockRangeForRenderUpdate(pos, pos); - } - return true; - } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) - { - TileEntity te = world.getTileEntity(pos); - if(te instanceof CustomTileEntity) - { - CustomTileEntity cte = (CustomTileEntity) te; - return cte.getState(); - } - return state; - } - - @Override - protected BlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[0], properties); - } - } - - public static class CustomTileEntity extends TileEntity - { - private IExtendedBlockState state; - public CustomTileEntity() {} - - public IExtendedBlockState getState() - { - if(state == null) - { - state = (IExtendedBlockState)getBlockType().getDefaultState(); - } - return state; - } - - public void setState(IExtendedBlockState state) - { - this.state = state; - } - } - - public static class CustomModel implements IBakedModel, ISmartBlockModel, ISmartItemModel - { - private final TextureAtlasSprite base, overlay; - //private boolean hasStateSet = false; - private final IExtendedBlockState state; - - public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay) - { - this(base, overlay, null); - } - - public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay, IExtendedBlockState state) - { - this.base = base; - this.overlay = overlay; - this.state = state; - } - - @Override - public List getFaceQuads(EnumFacing side) - { - return Collections.emptyList(); - } - - private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v) - { - return new int[] { - Float.floatToRawIntBits(x), - Float.floatToRawIntBits(y), - Float.floatToRawIntBits(z), - color, - Float.floatToRawIntBits(texture.getInterpolatedU(u)), - Float.floatToRawIntBits(texture.getInterpolatedV(v)), - 0 - }; - } - - private BakedQuad createSidedBakedQuad(float x1, float x2, float z1, float z2, float y, TextureAtlasSprite texture, EnumFacing side) - { - Vec3 v1 = rotate(new Vec3(x1 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5); - Vec3 v2 = rotate(new Vec3(x1 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5); - Vec3 v3 = rotate(new Vec3(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5); - Vec3 v4 = rotate(new Vec3(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5); - return new BakedQuad(Ints.concat( - vertexToInts((float)v1.xCoord, (float)v1.yCoord, (float)v1.zCoord, -1, texture, 0, 0), - vertexToInts((float)v2.xCoord, (float)v2.yCoord, (float)v2.zCoord, -1, texture, 0, 16), - vertexToInts((float)v3.xCoord, (float)v3.yCoord, (float)v3.zCoord, -1, texture, 16, 16), - vertexToInts((float)v4.xCoord, (float)v4.yCoord, (float)v4.zCoord, -1, texture, 16, 0) - ), -1, side); - } - - @Override - public List getGeneralQuads() - { - int len = cubeSize * 5 + 1; - List ret = new ArrayList(); - for(EnumFacing f : EnumFacing.values()) - { - ret.add(createSidedBakedQuad(0, 1, 0, 1, 1, base, f)); - for(int i = 0; i < cubeSize; i++) - { - for(int j = 0; j < cubeSize; j++) - { - if(state != null) - { - Integer value = state.getValue(properties[f.ordinal()]); - if(value != null && (value & (1 << (i * cubeSize + j))) != 0) - { - ret.add(createSidedBakedQuad((float)(1 + i * 5) / len, (float)(5 + i * 5) / len, (float)(1 + j * 5) / len, (float)(5 + j * 5) / len, 1.0001f, overlay, f)); - } - } - } - } - } - return ret; - } - - @Override - public boolean isGui3d() { return true; } - - @Override - public boolean isAmbientOcclusion() { return true; } - - @Override - public boolean isBuiltInRenderer() { return false; } - - @Override - public TextureAtlasSprite getParticleTexture() { return this.base; } - - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } - - @Override - public IBakedModel handleBlockState(IBlockState state) - { - return new CustomModel(base, overlay, (IExtendedBlockState)state); - } - - @Override - public IBakedModel handleItemState(ItemStack stack) - { - IExtendedBlockState itemState = ((IExtendedBlockState)CustomModelBlock.instance.getDefaultState()).withProperty(properties[1], (1 << (cubeSize * cubeSize)) - 1); - return new CustomModel(base, overlay, itemState); - } - } - - private static Vec3 rotate(Vec3 vec, EnumFacing side) - { - switch(side) - { - case DOWN: return new Vec3( vec.xCoord, -vec.yCoord, -vec.zCoord); - case UP: return new Vec3( vec.xCoord, vec.yCoord, vec.zCoord); - case NORTH: return new Vec3( vec.xCoord, vec.zCoord, -vec.yCoord); - case SOUTH: return new Vec3( vec.xCoord, -vec.zCoord, vec.yCoord); - case WEST: return new Vec3(-vec.yCoord, vec.xCoord, vec.zCoord); - case EAST: return new Vec3( vec.yCoord, -vec.xCoord, vec.zCoord); - } - return null; - } - - private static Vec3 revRotate(Vec3 vec, EnumFacing side) - { - switch(side) - { - case DOWN: return new Vec3( vec.xCoord, -vec.yCoord, -vec.zCoord); - case UP: return new Vec3( vec.xCoord, vec.yCoord, vec.zCoord); - case NORTH: return new Vec3( vec.xCoord, -vec.zCoord, vec.yCoord); - case SOUTH: return new Vec3( vec.xCoord, vec.zCoord, -vec.yCoord); - case WEST: return new Vec3( vec.yCoord, -vec.xCoord, vec.zCoord); - case EAST: return new Vec3(-vec.yCoord, vec.xCoord, vec.zCoord); - } - return null; - } -} diff --git a/src/main/java/net/minecraftforge/debug/ModelFluidDebug.java b/src/main/java/net/minecraftforge/debug/ModelFluidDebug.java deleted file mode 100644 index 65acdd56c..000000000 --- a/src/main/java/net/minecraftforge/debug/ModelFluidDebug.java +++ /dev/null @@ -1,194 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.ItemMeshDefinition; -import net.minecraft.client.renderer.block.statemap.StateMapperBase; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fluids.BlockFluidClassic; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -@Mod(modid = ModelFluidDebug.MODID, version = ModelFluidDebug.VERSION) -public class ModelFluidDebug -{ - public static final String MODID = "ForgeDebugModelFluid"; - public static final String VERSION = "1.0"; - - @SidedProxy - public static CommonProxy proxy; - - public static final Fluid milkFluid = new Fluid("milk", new ResourceLocation("forge", "blocks/milk_still"), new ResourceLocation("forge", "blocks/milk_flow")); - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } - - public static class CommonProxy - { - public void preInit(FMLPreInitializationEvent event) - { - FluidRegistry.registerFluid(TestFluid.instance); - FluidRegistry.registerFluid(TestGas.instance); - FluidRegistry.registerFluid(milkFluid); - GameRegistry.registerBlock(TestFluidBlock.instance, TestFluidBlock.name); - GameRegistry.registerBlock(TestGasBlock.instance, TestGasBlock.name); - GameRegistry.registerBlock(MilkFluidBlock.instance, MilkFluidBlock.name); - } - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - private static ModelResourceLocation fluidLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestFluidBlock.name, "fluid"); - private static ModelResourceLocation gasLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestFluidBlock.name, "gas"); - private static ModelResourceLocation milkLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestFluidBlock.name, "milk"); - - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - Item fluid = Item.getItemFromBlock(TestFluidBlock.instance); - Item gas = Item.getItemFromBlock(TestGasBlock.instance); - Item milk = Item.getItemFromBlock(MilkFluidBlock.instance); - // no need to pass the locations here, since they'll be loaded by the block model logic. - ModelBakery.registerItemVariants(fluid); - ModelBakery.registerItemVariants(gas); - ModelBakery.registerItemVariants(milk); - ModelLoader.setCustomMeshDefinition(fluid, new ItemMeshDefinition() - { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - return fluidLocation; - } - }); - ModelLoader.setCustomMeshDefinition(gas, new ItemMeshDefinition() - { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - return gasLocation; - } - }); - ModelLoader.setCustomMeshDefinition(milk, new ItemMeshDefinition() - { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - return milkLocation; - } - }); - ModelLoader.setCustomStateMapper(TestFluidBlock.instance, new StateMapperBase() - { - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state) - { - return fluidLocation; - } - }); - ModelLoader.setCustomStateMapper(TestGasBlock.instance, new StateMapperBase() - { - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state) - { - return gasLocation; - } - }); - ModelLoader.setCustomStateMapper(MilkFluidBlock.instance, new StateMapperBase() - { - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state) - { - return milkLocation; - } - }); - } - } - - public static final class TestFluid extends Fluid - { - public static final String name = "testfluid"; - public static final TestFluid instance = new TestFluid(); - - private TestFluid() - { - super(name, new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow")); - } - - @Override - public int getColor() - { - return 0xFF00FF00; - } - } - - public static final class TestGas extends Fluid - { - public static final String name = "testgas"; - public static final TestGas instance = new TestGas(); - - private TestGas() - { - super(name, new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow")); - density = -1000; - isGaseous = true; - } - - @Override - public int getColor() - { - return 0xFFFF0000; - } - } - - public static final class TestFluidBlock extends BlockFluidClassic - { - public static final TestFluidBlock instance = new TestFluidBlock(); - public static final String name = "TestFluidBlock"; - - private TestFluidBlock() - { - super(TestFluid.instance, Material.water); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - } - - public static final class MilkFluidBlock extends BlockFluidClassic - { - public static final MilkFluidBlock instance = new MilkFluidBlock(); - public static final String name = "MilkFluidBlock"; - - private MilkFluidBlock() - { - super(milkFluid, Material.water); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - } - - public static final class TestGasBlock extends BlockFluidClassic - { - public static final TestGasBlock instance = new TestGasBlock(); - public static final String name = "TestGasBlock"; - - private TestGasBlock() - { - super(TestGas.instance, Material.lava); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java b/src/main/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java deleted file mode 100644 index 886bb3b3b..000000000 --- a/src/main/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java +++ /dev/null @@ -1,830 +0,0 @@ -package net.minecraftforge.debug; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.vecmath.AxisAngle4d; -import javax.vecmath.Matrix4f; -import javax.vecmath.Quat4f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector4f; - -import net.minecraft.block.Block; -import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.state.BlockState; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ITickable; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.client.model.TRSRTransformation; -import net.minecraftforge.client.model.b3d.B3DLoader; -import net.minecraftforge.client.model.obj.OBJLoader; -import net.minecraftforge.client.model.obj.OBJModel; -import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel; -import net.minecraftforge.common.property.ExtendedBlockState; -import net.minecraftforge.common.property.IExtendedBlockState; -import net.minecraftforge.common.property.IUnlistedProperty; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -@Mod(modid = ModelLoaderRegistryDebug.MODID, version = ModelLoaderRegistryDebug.VERSION) -public class ModelLoaderRegistryDebug -{ - public static final String MODID = "ForgeDebugModelLoaderRegistry"; - public static final String VERSION = "1.0"; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerBlock(CustomModelBlock.instance, CustomModelBlock.name); - GameRegistry.registerBlock(OBJTesseractBlock.instance, OBJTesseractBlock.name); - GameRegistry.registerBlock(OBJVertexColoring1.instance, OBJVertexColoring1.name); - GameRegistry.registerBlock(OBJDirectionEye.instance, OBJDirectionEye.name); - GameRegistry.registerBlock(OBJVertexColoring2.instance, OBJVertexColoring2.name); - GameRegistry.registerBlock(OBJDirectionBlock.instance, OBJDirectionBlock.name); - GameRegistry.registerBlock(OBJCustomDataBlock.instance, OBJCustomDataBlock.name); - GameRegistry.registerBlock(OBJDynamicEye.instance, OBJDynamicEye.name); - GameRegistry.registerTileEntity(OBJTesseractTileEntity.class, OBJTesseractBlock.name); - GameRegistry.registerTileEntity(OBJVertexColoring2TileEntity.class, OBJVertexColoring2.name); - GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name); - if (event.getSide() == Side.CLIENT) - clientPreInit(); - } - - private void clientPreInit() - { - B3DLoader.instance.addDomain(MODID.toLowerCase()); - Item item = Item.getItemFromBlock(CustomModelBlock.instance); - ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + CustomModelBlock.name, "inventory")); - - OBJLoader.instance.addDomain(MODID.toLowerCase()); - Item item2 = Item.getItemFromBlock(OBJTesseractBlock.instance); - ModelLoader.setCustomModelResourceLocation(item2, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJTesseractBlock.name, "inventory")); - - Item item3 = Item.getItemFromBlock(OBJVertexColoring1.instance); - ModelLoader.setCustomModelResourceLocation(item3, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJVertexColoring1.name, "inventory")); - - Item item4 = Item.getItemFromBlock(OBJDirectionEye.instance); - ModelLoader.setCustomModelResourceLocation(item4, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionEye.name, "inventory")); - - Item item5 = Item.getItemFromBlock(OBJVertexColoring2.instance); - ModelLoader.setCustomModelResourceLocation(item5, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJVertexColoring2.name, "inventory")); - - Item item6 = Item.getItemFromBlock(OBJDirectionBlock.instance); - ModelLoader.setCustomModelResourceLocation(item6, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionBlock.name, "inventory")); - - Item item7 = Item.getItemFromBlock(OBJCustomDataBlock.instance); - ModelLoader.setCustomModelResourceLocation(item7, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJCustomDataBlock.name, "inventory")); - - Item item8 = Item.getItemFromBlock(OBJDynamicEye.instance); - ModelLoader.setCustomModelResourceLocation(item8, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDynamicEye.name, "inventory")); - } - - public static class CustomModelBlock extends Block - { - public static final PropertyDirection FACING = PropertyDirection.create("facing"); - public static final CustomModelBlock instance = new CustomModelBlock(); - public static final String name = "CustomModelBlock"; - private int counter = 1; - public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{B3DLoader.B3DFrameProperty.instance}); - - private CustomModelBlock() - { - super(Material.iron); - this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - - @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) - { - return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, pos, placer)); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(FACING).getIndex(); - } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) - { - //Only return an IExtendedBlockState from this method and createState(), otherwise block placement might break! - B3DLoader.B3DState newState = new B3DLoader.B3DState(null, counter); - return ((IExtendedBlockState) state).withProperty(B3DLoader.B3DFrameProperty.instance, newState); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) - { - if(world.isRemote) - { - System.out.println("click " + counter); - if(player.isSneaking()) counter--; - else counter++; - //if(counter >= model.getNode().getKeys().size()) counter = 0; - world.markBlockRangeForRenderUpdate(pos, pos); - } - return false; - } - - @Override - public BlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{B3DLoader.B3DFrameProperty.instance}); - } - - public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) - { - if (MathHelper.abs((float)entityIn.posX - clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - clickedBlock.getZ()) < 2.0F) - { - double d0 = entityIn.posY + entityIn.getEyeHeight(); - - if (d0 - clickedBlock.getY() > 2.0D) - { - return EnumFacing.UP; - } - - if (clickedBlock.getY() - d0 > 0.0D) - { - return EnumFacing.DOWN; - } - } - - return entityIn.getHorizontalFacing().getOpposite(); - } - } - /** - * This block is intended to demonstrate how to change the visibility of a group(s) - * from within the block's class. - * By right clicking on this block the player increments an integer value in the tile entity - * for this block, which is then added to a list of strings and passed into the constructor - * for OBJState. NOTE: this trick only works if your groups are named '1', '2', '3', etc., - * otherwise they must be added by name. - * Holding shift decrements the value in the tile entity. - * @author shadekiller666 - * - */ - public static class OBJTesseractBlock extends Block implements ITileEntityProvider - { - public static final OBJTesseractBlock instance = new OBJTesseractBlock(); - public static final String name = "OBJTesseractBlock"; - private ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - - private OBJTesseractBlock() - { - super(Material.iron); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) - { - return new OBJTesseractTileEntity(); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) - { - OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos); - OBJModel.OBJState retState = new OBJModel.OBJState(tileEntity == null ? Lists.newArrayList(OBJModel.Group.ALL) : tileEntity.visible, true); - return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.instance, retState); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) - { - if (world.getTileEntity(pos) == null) world.setTileEntity(pos, new OBJTesseractTileEntity()); - OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos); - IModel model = ModelLoaderRegistry.getMissingModel(); - try - { - model = ModelLoaderRegistry.getModel(new ResourceLocation(MODID.toLowerCase() + ":" + "block/tesseract.obj")); - } - catch (IOException e) - { - model = ModelLoaderRegistry.getMissingModel(); - } - - if (player.isSneaking()) - { - tileEntity.decrement(); - } - else - { - if (model != ModelLoaderRegistry.getMissingModel()) - { - tileEntity.setMax(((OBJModel) model).getMatLib().getGroups().keySet().size() - 1); - tileEntity.increment(); - } - } - - if (world.isRemote) - { - OBJBakedModel objBaked = (OBJBakedModel) Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(state, world, pos); - objBaked.scheduleRebake(); //not necessarily needed for this specific case, but is available - } - world.markBlockRangeForRenderUpdate(pos, pos); - return false; - } - - @Override - public boolean hasTileEntity(IBlockState state) - { - return true; - } - } - - public static class OBJTesseractTileEntity extends TileEntity - { - private int counter = 1; - private int max = 2; - public List visible = new ArrayList(); - - public OBJTesseractTileEntity() - { - this.visible.add(OBJModel.Group.ALL); - } - - public void increment() - { - if (this.visible.contains(OBJModel.Group.ALL)) this.visible.remove(OBJModel.Group.ALL); - if (this.counter == max) - { - this.counter = 0; - this.visible.clear(); - } - this.counter++; - this.visible.add(Integer.toString(this.counter)); - ChatComponentText text = new ChatComponentText("" + this.counter); - if (this.worldObj.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(text); - } - - public void decrement() - { - if (this.visible.contains(OBJModel.Group.ALL)) this.visible.remove(OBJModel.Group.ALL); - if (this.counter == 1) - { - this.counter = max + 1; - for (int i = 1; i < max; i++) this.visible.add(Integer.toString(i)); - } - this.visible.remove(Integer.toString(this.counter)); - this.counter--; - ChatComponentText text = new ChatComponentText("" + this.counter); - if (this.worldObj.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(text); - } - - public void reset() - { - this.counter = 1; - this.max = 2; - this.visible.clear(); - this.visible.add(Integer.toString(this.counter)); - } - - public int getMax() - { - return this.max; - } - - public void setMax(int max) - { - this.max = max; - } - - public void setToMax() - { - this.counter = this.max; - } - } - - /** - * This block demonstrates how to utilize the vertex coloring feature - * of the OBJ loader. See 'vertex_coloring.obj' and 'vertex_coloring.mtl' in - * 'test/resources/assets/forgedebugmodelloaderregistry/models/block/', to properly - * utilize this feature an obj file must have 1 'usemtl' key before every vertex as shown, - * having less 'usemtl' lines than 'v' lines will result in the faces having that material's - * color instead of each vertex. - * @author shadekiller666 - * - */ - public static class OBJVertexColoring1 extends Block - { - public static final OBJVertexColoring1 instance = new OBJVertexColoring1(); - public static final String name = "OBJVertexColoring1"; - - private OBJVertexColoring1() - { - super(Material.iron); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(name); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - } - - /** - * This block demonstrates how to use IProperties and IUnlistedProperties together - * in the same ExtendedBlockState. Similar to pistons, this block will face the player - * when placed. Unlike pistons, however; this block's model is an eyeball, because - * the OBJ loader can load spheres. - * @author shadekiller666 - * - */ - public static class OBJDirectionEye extends Block - { - public static final PropertyDirection FACING = PropertyDirection.create("facing"); - public static final OBJDirectionEye instance = new OBJDirectionEye(); - public static final String name = "OBJDirectionEye"; - private ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[] {FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - - private OBJDirectionEye() - { - super(Material.iron); - setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(name); - } - - @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) - { - return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, pos, placer)); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(FACING).getIndex(); - } - - @Override - @SideOnly(Side.CLIENT) - public IBlockState getStateForEntityRender(IBlockState state) - { - return this.getDefaultState().withProperty(FACING, EnumFacing.NORTH); - } - - @Override - public BlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[] {FACING}, new IUnlistedProperty[] {OBJModel.OBJProperty.instance}); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) - { - EnumFacing facing = state.getValue(FACING); - TRSRTransformation transform = new TRSRTransformation(facing); - OBJModel.OBJState retState = new OBJModel.OBJState(Arrays.asList(new String[]{OBJModel.Group.ALL}), true, transform); - return ((IExtendedBlockState) state).withProperty(OBJModel.OBJProperty.instance, retState); - } - - public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) - { - if (MathHelper.abs((float)entityIn.posX - clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - clickedBlock.getZ()) < 2.0F) - { - double d0 = entityIn.posY + entityIn.getEyeHeight(); - - if (d0 - clickedBlock.getY() > 2.0D) - { - return EnumFacing.DOWN; - } - - if (clickedBlock.getY() - d0 > 0.0D) - { - return EnumFacing.UP; - } - } - - return entityIn.getHorizontalFacing(); - } - } - - /** - * This block uses the same model as CustomModelBlock3 does, but - * this class allows the player to cycle the colors of each vertex to black - * and then back to the original color when right clicking on the block. - * @author shadekiller666 - * - */ - public static class OBJVertexColoring2 extends Block implements ITileEntityProvider - { - public static final OBJVertexColoring2 instance = new OBJVertexColoring2(); - public static final String name = "OBJVertexColoring2"; - - private OBJVertexColoring2() - { - super(Material.iron); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(name); - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) - { - return new OBJVertexColoring2TileEntity(); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) - { - if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJVertexColoring2TileEntity) - { - ((OBJVertexColoring2TileEntity) world.getTileEntity(pos)).cycleColors(); - } - return false; - } - } - - public static class OBJVertexColoring2TileEntity extends TileEntity - { - private int index = 0; - private int maxIndex = 1; - private List colorList = new ArrayList(); - private boolean hasFilledList = false; - private boolean shouldIncrement = true; - - public OBJVertexColoring2TileEntity() {} - - public void cycleColors() - { - if (this.worldObj.isRemote) - { - FMLLog.info("%b", shouldIncrement); - IBakedModel bakedModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(this.worldObj.getBlockState(this.pos), this.worldObj, this.pos); - if (bakedModel != null && bakedModel instanceof OBJBakedModel) - { - OBJBakedModel objBaked = (OBJBakedModel) bakedModel; - ImmutableList materialNames = objBaked.getModel().getMatLib().getMaterialNames(); - if (!hasFilledList) - { - for (String name : materialNames) - { - if (!name.equals(OBJModel.Material.WHITE_NAME)) - { - colorList.add(objBaked.getModel().getMatLib().getMaterial(name).getColor()); - } - } - hasFilledList = true; - } - maxIndex = materialNames.size(); - if (this.shouldIncrement && index + 1 < maxIndex) - { - FMLLog.info("incrementing"); - String name = materialNames.get(index); - objBaked.getModel().getMatLib().changeMaterialColor(name, 0xFF000000); - objBaked.scheduleRebake(); - index++; - } - else if (index - 1 >= 0) - { - index--; - this.shouldIncrement = index == 0; - int color = 0; - color |= (int) (colorList.get(index).getW() * 255) << 24; - color |= (int) (colorList.get(index).getX() * 255) << 16; - color |= (int) (colorList.get(index).getY() * 255) << 8; - color |= (int) (colorList.get(index).getZ() * 255); - String name = materialNames.get(index); - if (!name.equals(OBJModel.Material.WHITE_NAME)) - { - objBaked.getModel().getMatLib().changeMaterialColor(name, color); - objBaked.scheduleRebake(); - } - } - this.worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos); - } - } - } - } - - /** - * This block is a debug block that faces the player when placed, like a piston. - * @author shadekiller666 - * - */ - public static class OBJDirectionBlock extends Block - { - public static final PropertyDirection FACING = PropertyDirection.create("facing"); - public static final OBJDirectionBlock instance = new OBJDirectionBlock(); - public static final String name = "OBJDirectionBlock"; - public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - - private OBJDirectionBlock() - { - super(Material.iron); - this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean isVisuallyOpaque() { return false; } - - @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) - { - return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, pos, placer)); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(FACING).getIndex(); - } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) - { - //Only return an IExtendedBlockState from this method and createState(), otherwise block placement will break! - EnumFacing facing = state.getValue(FACING); - TRSRTransformation transform = new TRSRTransformation(facing); - OBJModel.OBJState newState = new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true, transform); - return ((IExtendedBlockState) state).withProperty(OBJModel.OBJProperty.instance, newState); - } - - @Override - public BlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - } - - public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) - { - if (MathHelper.abs((float)entityIn.posX - clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - clickedBlock.getZ()) < 2.0F) - { - double d0 = entityIn.posY + entityIn.getEyeHeight(); - - if (d0 - clickedBlock.getY() > 2.0D) - { - return EnumFacing.UP; - } - - if (clickedBlock.getY() - d0 > 0.0D) - { - return EnumFacing.DOWN; - } - } - - return entityIn.getHorizontalFacing().getOpposite(); - } - } - - /** - * This block is a testing block that will be used to test the use - * of "custom" data defined in a forge blockstate json. WIP, ignore for now. - * @author shadekiller666 - * - */ - public static class OBJCustomDataBlock extends Block - { - public static final PropertyBool NORTH = PropertyBool.create("north"); - public static final PropertyBool SOUTH = PropertyBool.create("south"); - public static final PropertyBool WEST = PropertyBool.create("west"); - public static final PropertyBool EAST = PropertyBool.create("east"); - public static final OBJCustomDataBlock instance = new OBJCustomDataBlock(); - public static final String name = "OBJCustomDataBlock"; - - private OBJCustomDataBlock() - { - super(Material.iron); - this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, false).withProperty(SOUTH, false).withProperty(WEST, false).withProperty(EAST, false)); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean isFullCube() - { - return false; - } - - @Override - public int getMetaFromState(IBlockState state) - { - return 0; - } - - public boolean canConnectTo(IBlockAccess world, BlockPos pos) - { - Block block = world.getBlockState(pos).getBlock(); - return block instanceof OBJCustomDataBlock; - } - - @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) - { - return state.withProperty(NORTH, this.canConnectTo(world, pos.north())).withProperty(SOUTH, this.canConnectTo(world, pos.south())).withProperty(WEST, this.canConnectTo(world, pos.west())).withProperty(EAST, this.canConnectTo(world, pos.east())); - } - - @Override - public BlockState createBlockState() - { - return new BlockState(this, new IProperty[]{NORTH, SOUTH, WEST, EAST}); - } - } - - /** - * This block uses the same model as CustomModelBlock4, but instead of facing the - * player when placed, this one ALWAYS faces the player. I know, creepy right? - * @author shadekiller666 - * - */ - public static class OBJDynamicEye extends Block implements ITileEntityProvider - { - public static final OBJDynamicEye instance = new OBJDynamicEye(); - public static final String name = "OBJDynamicEye"; - public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {OBJModel.OBJProperty.instance}); - private OBJDynamicEye() - { - super(Material.iron); - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + ":" + name); - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) - { - return new OBJDynamicEyeTileEntity(); - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean isFullCube() - { - return false; - } - - @Override - public boolean hasTileEntity(IBlockState state) - { - return true; - } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) - { - if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJDynamicEyeTileEntity) - { - OBJDynamicEyeTileEntity te = (OBJDynamicEyeTileEntity) world.getTileEntity(pos); - if (te.state != null) - { - return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.instance, te.state); - } - } - return state; - } - - @Override - public BlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {OBJModel.OBJProperty.instance}); - } - } - - public static class OBJDynamicEyeTileEntity extends TileEntity implements ITickable - { - public OBJModel.OBJState state; - - public OBJDynamicEyeTileEntity() - { - this.state = new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true); - } - - @Override - public void update() - { - if (this.worldObj.isRemote) - { - Vector3d teLoc = new Vector3d(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - Vector3d playerLoc = new Vector3d(); - playerLoc.setX(player.posX); - playerLoc.setY(player.posY + player.getEyeHeight()); - playerLoc.setZ(player.posZ); - Vector3d lookVec = new Vector3d(playerLoc.getX() - teLoc.getX(), playerLoc.getY() - teLoc.getY(), playerLoc.getZ() - teLoc.getZ()); - double angleYaw = Math.atan2(lookVec.getZ(), lookVec.getX()) - Math.PI/2d; - double anglePitch = Math.atan2(lookVec.getY(), Math.sqrt(lookVec.getX() * lookVec.getX() + lookVec.getZ() * lookVec.getZ())); - AxisAngle4d yaw = new AxisAngle4d(0, 1, 0, -angleYaw); - AxisAngle4d pitch = new AxisAngle4d(1, 0, 0, -anglePitch); - Quat4f rot = new Quat4f(0, 0, 0, 1); - Quat4f yawQuat = new Quat4f(); - Quat4f pitchQuat = new Quat4f(); - yawQuat.set(yaw); - rot.mul(yawQuat); - pitchQuat.set(pitch); - rot.mul(pitchQuat); - Matrix4f matrix = new Matrix4f(); - matrix.setIdentity(); - matrix.setRotation(rot); - TRSRTransformation transform = new TRSRTransformation(matrix); - transform = TRSRTransformation.blockCenterToCorner(transform); - this.state = new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true, transform); - this.worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos); - } - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/MultiLayerModelDebug.java b/src/main/java/net/minecraftforge/debug/MultiLayerModelDebug.java deleted file mode 100644 index 061f884bc..000000000 --- a/src/main/java/net/minecraftforge/debug/MultiLayerModelDebug.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraftforge.client.model.ModelLoader; -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.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -@Mod(modid = MultiLayerModelDebug.MODID, version = MultiLayerModelDebug.VERSION) -public class MultiLayerModelDebug -{ - public static final String MODID = "forgedebugmultilayermodel"; - public static final String VERSION = "0.0"; - - public static String blockName = "test_layer_block"; - - @SidedProxy - public static CommonProxy proxy; - - public static class CommonProxy - { - public void preInit(FMLPreInitializationEvent event) - { - GameRegistry.registerBlock(new Block(Material.wood) - { - { - setCreativeTab(CreativeTabs.tabBlock); - setUnlocalizedName(MODID + "." + blockName); - } - - @Override - public boolean isOpaqueCube() { return false; } - - @Override - public boolean isFullCube() { return false; } - - @Override - public boolean canRenderInLayer(EnumWorldBlockLayer layer) - { - return layer == EnumWorldBlockLayer.SOLID || layer == EnumWorldBlockLayer.TRANSLUCENT; - } - }, blockName); - } - } - - public static class ServerProxy extends CommonProxy {} - - public static class ClientProxy extends CommonProxy - { - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GameRegistry.findBlock(MODID, blockName)), 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + blockName, "inventory")); - } - } - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } -} diff --git a/src/main/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java b/src/main/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java deleted file mode 100644 index f8d779140..000000000 --- a/src/main/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.minecraftforge.debug; - -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -@Mod( modid = NoPotionEffectRenderTest.modID, name = "No Potion Effect Render Test", version = "0.0.0" ) -public class NoPotionEffectRenderTest { - public static final String modID = "nopotioneffect"; - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) { - TestPotion INSTANCE = new TestPotion(30, new ResourceLocation(modID, "test_potion"), false, 0xff00ff); - } - - public static class TestPotion extends Potion { - - public TestPotion(int potionID, ResourceLocation location, boolean badEffect, int potionColor) { - super(potionID, location, badEffect, potionColor); - } - - @Override - public boolean shouldRender(PotionEffect effect) { - return false; - } - } -} diff --git a/src/main/java/net/minecraftforge/debug/PotionRegistryDebug.java b/src/main/java/net/minecraftforge/debug/PotionRegistryDebug.java deleted file mode 100644 index 5a60a0260..000000000 --- a/src/main/java/net/minecraftforge/debug/PotionRegistryDebug.java +++ /dev/null @@ -1,82 +0,0 @@ -package net.minecraftforge.debug; - -import gnu.trove.set.TIntSet; -import gnu.trove.set.hash.TIntHashSet; - -import java.util.Random; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -@Mod(modid=PotionRegistryDebug.MODID) -public class PotionRegistryDebug { - public static final String MODID = "ForgePotionRegistry"; - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) { - new PotionForge(new ResourceLocation("forge", "forge"), false, 0xff00ff); // test automatic id distribution - new PotionForge(200, new ResourceLocation("forge", "forgy"), true, 0x00ff00); // test that ids above 127 work - - Random rand = new Random(); - TIntSet taken = new TIntHashSet(100); - int ra = rand.nextInt(100) + 100; - taken.add(ra); - - // a new potion with a random id so that forge has to remap it - new PotionForge(ra, new ResourceLocation("forge", "realRandomPotion"), false, 0x0000ff); - - for(int i = 0; i < 20; i++) { - int r = rand.nextInt(200) + 35; - while(taken.contains(r)) - r = rand.nextInt(200) + 35; - //r = 32+i; - taken.add(r); - // this potions will most likely not have the same IDs between server and client. - // The forge handshake on connect should fix this. - new PotionForge(r, new ResourceLocation("forge", "randomPotion" + r), false, 0xff00ff); - } - } - - protected class PotionForge extends Potion { - - public PotionForge(int potionID, ResourceLocation location, boolean badEffect, int potionColor) { - super(potionID, location, badEffect, potionColor); - setPotionName("potion." + location.getResourcePath()); - } - - protected PotionForge(ResourceLocation location, boolean badEffect, int potionColor) { - super(location, badEffect, potionColor); - setPotionName("potion." + location.getResourcePath()); - } - - @Override - public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - - mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); - TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite("minecraft:blocks/fire_layer_0"); - - x += 6; - y += 7; - - int width = 18; - int height = width; -/* - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.startDrawingQuads(); - worldrenderer.setColorOpaque_I(potion.getLiquidColor()); - worldrenderer.addVertexWithUV((double) x, (double) (y + height), 0.0D, sprite.getMinU(), sprite.getMaxV()); - worldrenderer.addVertexWithUV((double)(x + width), (double)(y + height), 0.0D, sprite.getMaxU(), sprite.getMaxV()); - worldrenderer.addVertexWithUV((double)(x + width), (double)y, 0.0D, sprite.getMaxU(), sprite.getMinV()); - worldrenderer.addVertexWithUV((double)x, (double)y, 0.0D, sprite.getMinU(), sprite.getMinV()); - tessellator.draw();*/ - } - } -} diff --git a/src/main/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json b/src/main/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json deleted file mode 100644 index 15a23f01c..000000000 --- a/src/main/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "forge_marker": 1, - "defaults": { - "model": "forge:multi-layer", - "custom": { - // base is used for model properties - camera transforms, isGui3d, e.t.c. - "base": "forgedebugmultilayermodel:test_layer_block#aux", - // per-layer models - "Solid": "forgedebugmultilayermodel:test_layer_block#aux", - "Translucent": "minecraft:pink_stained_glass_pane#east=true,north=false,south=false,west=true" - }, - "transform": "forge:default-block" - }, - "variants": { - "normal": [{}], - "inventory": [{}], - "aux": [{ - "model": "cube_all", - "textures": { "all": "blocks/slime" }, - "transform": { "scale": .5 } - }] - } -}