Fix #1150 and add ISpriteRegistrer

This commit is contained in:
Nedelosk committed 2016-05-01 15:44:10 +02:00
1 parent efd4a33bbb
commit 24979f18f6
31 files changed
+231 -56

No files matched your search

@@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface ISpriteRegister {
@SideOnly(Side.CLIENT)
void registerSprites(ITextureManager manager);
}
@@ -952,7 +952,6 @@ public class PluginApiculture extends BlankForestryPlugin {
EntityFXSnow.sprites[i] = event.map.registerSprite(new ResourceLocation("forestry:entity/particles/snow." + (i + 1)));
}
EntityFXBee.beeSprite = event.map.registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
ItemHabitatLocator.registerSprite();
}
private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule {
@@ -20,6 +20,7 @@ import forestry.apiculture.tiles.TileApiaristChest;
import forestry.core.blocks.IBlockTypeTesr;
import forestry.core.blocks.IMachinePropertiesTesr;
import forestry.core.blocks.MachinePropertiesTesr;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileForestry;
import forestry.core.tiles.TileNaturalistChest;
@@ -34,9 +35,9 @@ public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
<T extends TileForestry> BlockTypeApicultureTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nullable AxisAlignedBB boundingBox) {
if (boundingBox != null) {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, boundingBox);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, boundingBox, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
} else {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
}
}
@@ -26,6 +26,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.ITextureManager;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.apiculture.gui.ContainerHabitatLocator;
@@ -35,7 +37,7 @@ import forestry.apiculture.render.TextureHabitatLocator;
import forestry.core.items.ItemWithGui;
import forestry.core.utils.Translator;
public class ItemHabitatLocator extends ItemWithGui {
public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
private static final String iconName = "forestry:items/biomefinder";
private final HabitatLocatorLogic locatorLogic;
@@ -59,7 +61,7 @@ public class ItemHabitatLocator extends ItemWithGui {
/* SPRITES */
@SideOnly(Side.CLIENT)
public static void registerSprite() {
public void registerSprites(ITextureManager manager) {
TextureAtlasSprite texture = new TextureHabitatLocator(iconName);
Minecraft.getMinecraft().getTextureMapBlocks().setTextureEntry(iconName, texture);
}
@@ -20,6 +20,7 @@ import forestry.arboriculture.tiles.TileArboristChest;
import forestry.core.blocks.IBlockTypeTesr;
import forestry.core.blocks.IMachinePropertiesTesr;
import forestry.core.blocks.MachinePropertiesTesr;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileForestry;
import forestry.core.tiles.TileNaturalistChest;
@@ -34,9 +35,9 @@ public enum BlockTypeArboricultureTesr implements IBlockTypeTesr {
<T extends TileForestry> BlockTypeArboricultureTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nullable AxisAlignedBB boundingBox) {
if (boundingBox != null) {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, boundingBox);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, boundingBox, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
} else {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
}
}
@@ -21,6 +21,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -55,6 +56,7 @@ import forestry.core.multiblock.MultiblockLogicFactory;
import forestry.core.network.IPacketRegistry;
import forestry.core.network.PacketRegistryCore;
import forestry.core.recipes.RecipeUtil;
import forestry.core.render.TextureManager;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.ForestryModEnvWarningCallable;
import forestry.plugins.BlankForestryPlugin;
@@ -368,4 +370,10 @@ public class PluginCore extends BlankForestryPlugin {
public void onBakeModel(ModelBakeEvent event) {
ModelManager.registerCustomModels(event);
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerSprites(TextureStitchEvent.Pre event) {
TextureManager.registerSprites();
}
}
@@ -19,6 +19,8 @@ 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.particle.EffectRenderer;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
@@ -32,6 +34,7 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -42,12 +45,17 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.ITextureManager;
import forestry.core.access.IAccessHandler;
import forestry.core.circuits.ISocketable;
import forestry.core.fluids.FluidHelper;
import forestry.core.proxy.Proxies;
import forestry.core.render.MachineParticleCallback;
import forestry.core.render.MachineStateMapper;
import forestry.core.render.ParticleHelper;
import forestry.core.render.TextureManager;
import forestry.core.tiles.TileBase;
import forestry.core.tiles.TileForestry;
import forestry.core.tiles.TileUtil;
@@ -56,7 +64,7 @@ import forestry.core.utils.PlayerUtil;
import jline.internal.Log;
public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> extends BlockForestry implements IItemModelRegister, IStateMapperRegister, IBlockWithMeta {
public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> extends BlockForestry implements IItemModelRegister, ISpriteRegister, IStateMapperRegister, IBlockWithMeta {
private final Map<P, IMachineProperties> properties = new HashMap<>();
private final boolean hasTESR;
private final boolean hasCustom;
@@ -66,6 +74,8 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
private final PropertyEnum<P> TYPE;
private final PropertyEnum<EnumFacing> FACE;
private final ParticleHelper.Callback particleCallback;
protected final BlockState blockState;
private boolean canCreateProps = false;
@@ -86,6 +96,8 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
this.blockState = this.createBlockState();
IBlockState state = this.blockState.getBaseState().withProperty(FACE, EnumFacing.NORTH);
this.setDefaultState(state);
particleCallback = new MachineParticleCallback(this, TYPE);
}
public PropertyEnum<P> getTypeProperty() {
@@ -323,8 +335,45 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
public boolean getUseNeighborBrightness() {
return hasTESR;
}
/* Particles */
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer) {
IBlockState state = world.getBlockState(target.getBlockPos());
P protety = state.getValue(TYPE);
if(protety.getMachineProperties() instanceof IMachinePropertiesTesr){
return ParticleHelper.addHitEffects(world, this, target, effectRenderer, particleCallback);
}
return false;
}
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World world, BlockPos pos, EffectRenderer effectRenderer) {
IBlockState state = world.getBlockState(pos);
P protety = state.getValue(TYPE);
if(protety.getMachineProperties() instanceof IMachinePropertiesTesr){
return ParticleHelper.addDestroyEffects(world, this, world.getBlockState(pos), pos, effectRenderer, particleCallback);
}
return false;
}
public final ItemStack get(P type) {
return new ItemStack(this, 1, type.getMachineProperties().getMeta());
}
@SideOnly(Side.CLIENT)
@Override
public void registerSprites(ITextureManager manager) {
for(P property : properties.keySet()){
if(property.getMachineProperties() instanceof IMachinePropertiesTesr){
Proxies.common.getClientInstance().getTextureMapBlocks().registerSprite(new ResourceLocation(((IMachinePropertiesTesr)property.getMachineProperties()).getParticleTextureLocation()));
}
}
}
}
@@ -10,6 +10,11 @@
******************************************************************************/
package forestry.core.blocks;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class BlockCore extends BlockBase<BlockTypeCoreTesr> {
public BlockCore() {
super(BlockTypeCoreTesr.class);
@@ -14,7 +14,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileAnalyzer;
import forestry.core.tiles.TileEscritoire;
@@ -30,7 +30,7 @@ public enum BlockTypeCoreTesr implements IBlockTypeTesr {
private final IMachinePropertiesTesr machineProperties;
<T extends TileForestry> BlockTypeCoreTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<T> renderer) {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
}
@Nonnull
@@ -12,6 +12,8 @@ package forestry.core.blocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import javax.annotation.Nonnull;
import forestry.core.tiles.TileForestry;
public interface IMachinePropertiesTesr<T extends TileForestry> extends IMachineProperties<T> {
@@ -20,4 +22,7 @@ public interface IMachinePropertiesTesr<T extends TileForestry> extends IMachine
* @return The renderer from the machine
*/
TileEntitySpecialRenderer<? super T> getRenderer();
@Nonnull
String getParticleTextureLocation();
}
@@ -17,15 +17,19 @@ import forestry.core.tiles.TileForestry;
public class MachinePropertiesTesr<T extends TileForestry> extends MachineProperties<T> implements IMachinePropertiesTesr<T> {
@Nullable
private final TileEntitySpecialRenderer<? super T> renderer;
@Nonnull
private final String particleTextureLocation;
public MachinePropertiesTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer) {
public MachinePropertiesTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, String particleTextureLocation) {
super(meta, teClass, name);
this.renderer = renderer;
this.particleTextureLocation = particleTextureLocation;
}
public MachinePropertiesTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nonnull AxisAlignedBB boundingBox) {
public MachinePropertiesTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nonnull AxisAlignedBB boundingBox, String particleTextureLocation) {
super(meta, teClass, name, boundingBox);
this.renderer = renderer;
this.particleTextureLocation = particleTextureLocation;
}
@Nullable
@@ -45,4 +49,10 @@ public class MachinePropertiesTesr<T extends TileForestry> extends MachineProper
}
}
}
@Nonnull
@Override
public String getParticleTextureLocation() {
return particleTextureLocation;
}
}
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.render;
import forestry.core.blocks.BlockBase;
import forestry.core.blocks.IBlockType;
import forestry.core.blocks.IMachinePropertiesTesr;
import forestry.core.proxy.Proxies;
import net.minecraft.block.Block;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
public class MachineParticleCallback<P extends Enum<P> & IBlockType & IStringSerializable> extends ParticleHelper.DefaultCallback<BlockBase> {
private final PropertyEnum<P> TYPE;
public MachineParticleCallback(BlockBase block, PropertyEnum<P> TYPE) {
super(block);
this.TYPE = TYPE;
}
@Override
protected void setTexture(EntityDiggingFX fx, BlockPos pos, IBlockState state) {
P protety = state.getValue(TYPE);
if(protety.getMachineProperties() instanceof IMachinePropertiesTesr){
fx.setParticleIcon(Proxies.common.getClientInstance().getTextureMapBlocks().getAtlasSprite(((IMachinePropertiesTesr)protety.getMachineProperties()).getParticleTextureLocation()));
}
}
}
@@ -116,11 +116,11 @@ public class ParticleHelper {
void addDestroyEffects(EntityDiggingFX fx, BlockPos pos, IBlockState state);
}
public static class DefaultCallback implements ParticleHelper.Callback {
public static class DefaultCallback<B extends Block> implements ParticleHelper.Callback {
private final Block block;
protected final B block;
public DefaultCallback(Block block) {
public DefaultCallback(B block) {
this.block = block;
}
@@ -141,4 +141,20 @@ public class ParticleHelper {
fx.setParticleIcon(Proxies.common.getClientInstance().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state));
}
}
public static class TexturedCallback extends ParticleHelper.DefaultCallback{
private final String textureLocation;
public TexturedCallback(Block block, String textureLocation) {
super(block);
this.textureLocation = textureLocation;
}
@Override
protected void setTexture(EntityDiggingFX fx, BlockPos pos, IBlockState state) {
fx.setParticleIcon(Proxies.common.getClientInstance().getTextureMapBlocks().getAtlasSprite(textureLocation));
}
}
}
@@ -89,16 +89,15 @@ public class RenderMachine extends TileEntitySpecialRenderer<TileBase> {
public void renderTileEntityAt(TileBase tile, double x, double y, double z, float partialTicks, int destroyStage) {
if (tile != null) {
IRenderableTile generator = (IRenderableTile) tile;
render(generator.getResourceTankInfo(), generator.getProductTankInfo(), generator.getOrientation(), x, y, z);
render(generator.getResourceTankInfo(), generator.getProductTankInfo(), generator.getOrientation(), x, y, z, destroyStage);
} else {
render(TankRenderInfo.EMPTY, TankRenderInfo.EMPTY, EnumFacing.SOUTH, x, y, z);
render(TankRenderInfo.EMPTY, TankRenderInfo.EMPTY, EnumFacing.SOUTH, x, y, z, -1);
}
}
private void render(TankRenderInfo resourceTankInfo, TankRenderInfo productTankInfo, EnumFacing orientation, double x, double y, double z) {
private void render(TankRenderInfo resourceTankInfo, TankRenderInfo productTankInfo, EnumFacing orientation, double x, double y, double z, int destroyStage) {
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y, (float) z);
float[] angle = {0, 0, 0};
if (orientation == null) {
@@ -145,15 +144,17 @@ public class RenderMachine extends TileEntitySpecialRenderer<TileBase> {
productTank.rotateAngleZ = angle[2];
float factor = (float) (1.0 / 16.0);
Proxies.render.bindTexture(textureBase);
Proxies.render.bindTexture(textureBase);
basefront.render(factor);
baseback.render(factor);
renderTank(resourceTank, textureResourceTank, resourceTankInfo, factor);
renderTank(productTank, textureProductTank, productTankInfo, factor);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
}
private void renderTank(ModelRenderer tankModel, ResourceLocation textureBase, TankRenderInfo renderInfo, float factor) {
@@ -15,15 +15,20 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.ISpriteProvider;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.ITextureManager;
import forestry.core.proxy.Proxies;
@@ -125,6 +130,20 @@ public class TextureManager implements ITextureManager {
return null;
}
@SideOnly(Side.CLIENT)
public static void registerSprites() {
for (Block block : GameData.getBlockRegistry()) {
if (block instanceof ISpriteRegister) {
((ISpriteRegister) block).registerSprites(getInstance());
}
}
for (Item item : GameData.getItemRegistry()) {
if (item instanceof ISpriteRegister) {
((ISpriteRegister) item).registerSprites(getInstance());
}
}
}
private static class DefaultSpriteProvider implements ISpriteProvider {
private final Map<Short, TextureAtlasSprite> textures = new HashMap<>();
@@ -29,11 +29,11 @@ import forestry.energy.tiles.TileEnginePeat;
import forestry.energy.tiles.TileEuGenerator;
public enum BlockTypeEngine implements IBlockTypeTesr {
PEAT(createEngineProperties(0, TileEnginePeat.class, "peat", "/engine_copper_")),
BIOGAS(createEngineProperties(1, TileEngineBiogas.class, "biogas", "/engine_bronze_")),
CLOCKWORK(createEngineProperties(2, TileEngineClockwork.class, "clockwork", "/engine_clock_")),
ELECTRICAL(createEngineProperties(3, TileEngineElectric.class, "electrical", "/engine_tin_")),
GENERATOR(createMachineProperties(4, TileEuGenerator.class, "generator", "/generator_"));
PEAT(createEngineProperties(0, TileEnginePeat.class, "peat", "/engine_copper")),
BIOGAS(createEngineProperties(1, TileEngineBiogas.class, "biogas", "/engine_bronze")),
CLOCKWORK(createEngineProperties(2, TileEngineClockwork.class, "clockwork", "/engine_clock")),
ELECTRICAL(createEngineProperties(3, TileEngineElectric.class, "electrical", "/engine_tin")),
GENERATOR(createMachineProperties(4, TileEuGenerator.class, "generator", "/generator"));
public static final BlockTypeEngine[] VALUES = values();
@@ -45,13 +45,13 @@ public enum BlockTypeEngine implements IBlockTypeTesr {
}
protected static IMachinePropertiesTesr<?> createEngineProperties(int meta, @Nonnull Class<? extends TileEngine> teClass, @Nonnull String name, @Nonnull String textureName) {
TileEntitySpecialRenderer<TileEngine> renderer = PluginEnergy.proxy.getRenderDefaultEngine(Constants.TEXTURE_PATH_BLOCKS + textureName);
return new MachinePropertiesEngine<>(meta, teClass, name, renderer);
TileEntitySpecialRenderer<TileEngine> renderer = PluginEnergy.proxy.getRenderDefaultEngine(Constants.TEXTURE_PATH_BLOCKS + textureName + "_");
return new MachinePropertiesEngine<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks" + textureName + ".0");
}
protected static IMachinePropertiesTesr<?> createMachineProperties(int meta, @Nonnull Class<? extends TileBase> teClass, @Nonnull String name, @Nonnull String textureName) {
TileEntitySpecialRenderer<TileBase> renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + textureName);
return new MachinePropertiesTesr<>(meta, teClass, name, renderer);
TileEntitySpecialRenderer<TileBase> renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + textureName + "_");
return new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks" + textureName + ".0");
}
@Nonnull
@@ -13,8 +13,8 @@ import forestry.core.tiles.TileEngine;
import forestry.core.tiles.TileUtil;
public class MachinePropertiesEngine<T extends TileEngine> extends MachinePropertiesTesr<T> {
public MachinePropertiesEngine(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer) {
super(meta, teClass, name, renderer);
public MachinePropertiesEngine(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, String particleTextureLocation) {
super(meta, teClass, name, renderer, particleTextureLocation);
}
@Override
@@ -47,11 +47,11 @@ public enum BlockTypeFactoryTesr implements IBlockTypeTesr {
<T extends TileBase> BlockTypeFactoryTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name) {
TileEntitySpecialRenderer<TileBase> renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + "/" + name + "_");
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
}
<T extends TileBase> BlockTypeFactoryTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer) {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
}
@Nonnull
@@ -41,11 +41,5 @@ public class EventHandlerGreenhouse {
controller.onChange(EnumGreenhouseEventType.CAMOUFLAGE, event);
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTextureRemap(TextureStitchEvent.Pre event) {
BlockGreenhouseType.registerSprites();
}
}
@@ -45,6 +45,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ICamouflagedBlock;
import forestry.api.core.IModelManager;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.ITextureManager;
import forestry.api.core.Tabs;
import forestry.api.multiblock.IGreenhouseComponent;
import forestry.core.CreativeTabForestry;
@@ -64,7 +66,7 @@ import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
import forestry.greenhouse.tiles.TileGreenhouseValve;
import forestry.plugins.ForestryPluginUids;
public abstract class BlockGreenhouse extends BlockStructure {
public abstract class BlockGreenhouse extends BlockStructure implements ISpriteRegister {
public static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
@@ -300,6 +302,12 @@ public abstract class BlockGreenhouse extends BlockStructure {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forestry:greenhouse", "inventory"));
}
}
@SideOnly(Side.CLIENT)
@Override
public void registerSprites(ITextureManager manager) {
BlockGreenhouseType.registerSprites();
}
@Override
public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) {
@@ -14,7 +14,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.ITextureManager;
import forestry.core.render.TextureManager;
import forestry.greenhouse.blocks.BlockGreenhouse.State;
import forestry.greenhouse.tiles.TileGreenhouseHatch;
@@ -146,6 +146,10 @@ public enum BlockGreenhouseType {
}
}
public static EnumMap<BlockGreenhouseSprites, TextureAtlasSprite> getSprites() {
return sprites;
}
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
@@ -114,8 +114,6 @@ public class PluginLepidopterology extends BlankForestryPlugin {
@Override
public void preInit() {
MinecraftForge.EVENT_BUS.register(this);
ButterflyBranchDefinition.createAlleles();
AlleleButterflyEffect.createAlleles();
@@ -307,10 +305,4 @@ public class PluginLepidopterology extends BlankForestryPlugin {
public static float getSecondSerumChance() {
return secondSerumChance;
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerSprites(TextureStitchEvent.Pre event) {
ItemButterflyGE.registerSprites();
}
}
@@ -19,6 +19,7 @@ import net.minecraft.util.AxisAlignedBB;
import forestry.core.blocks.IBlockTypeTesr;
import forestry.core.blocks.IMachinePropertiesTesr;
import forestry.core.blocks.MachinePropertiesTesr;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileForestry;
import forestry.core.tiles.TileNaturalistChest;
@@ -34,9 +35,9 @@ public enum BlockTypeLepidopterologyTesr implements IBlockTypeTesr {
<T extends TileForestry> BlockTypeLepidopterologyTesr(int meta, @Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nullable AxisAlignedBB boundingBox) {
if (boundingBox != null) {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, boundingBox);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, boundingBox, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
} else {
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer);
this.machineProperties = new MachinePropertiesTesr<>(meta, teClass, name, renderer, Constants.RESOURCE_ID + ":blocks/" + name + ".0");
}
}
@@ -30,6 +30,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.core.IModelManager;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.ITextureManager;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
@@ -53,7 +55,7 @@ import forestry.lepidopterology.PluginLepidopterology;
import forestry.lepidopterology.entities.EntityButterfly;
import forestry.lepidopterology.genetics.ButterflyGenome;
public class ItemButterflyGE extends ItemGE {
public class ItemButterflyGE extends ItemGE implements ISpriteRegister {
private static final Random rand = new Random();
@@ -303,7 +305,7 @@ public class ItemButterflyGE extends ItemGE {
* Register butterfly item sprites
*/
@SideOnly(Side.CLIENT)
public static void registerSprites() {
public void registerSprites(ITextureManager manager) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleButterflySpecies) {
((IAlleleButterflySpecies) allele).getSpriteProvider().registerSprites();