Some cleanup, generics, whitespace, etc.

This commit is contained in:
cpw 2015-11-23 01:07:24 -05:00
parent aad2b93dc4
commit 3b63013739
6 changed files with 36 additions and 41 deletions

View File

@ -44,7 +44,7 @@ import com.google.common.collect.Lists;
public class BlockIronChest extends BlockContainer public class BlockIronChest extends BlockContainer
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", IronChestType.class); public static final PropertyEnum<IronChestType> VARIANT_PROP = PropertyEnum.create("variant", IronChestType.class);
public BlockIronChest() public BlockIronChest()
{ {
@ -102,7 +102,7 @@ public class BlockIronChest extends BlockContainer
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{ {
for (IronChestType type : IronChestType.values()) for (IronChestType type : IronChestType.values())
{ {
@ -128,7 +128,7 @@ public class BlockIronChest extends BlockContainer
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { VARIANT_PROP }); return new BlockState(this, new IProperty<?>[] { VARIANT_PROP });
} }
@Override @Override

View File

@ -20,7 +20,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:FML@[7.2,)", acceptedMinecraftVersions="[1.8,1.8.8]") @Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[11.14.4,]", acceptedMinecraftVersions="[1.8,1.8.8]")
public class IronChest public class IronChest
{ {
public static BlockIronChest ironChestBlock; public static BlockIronChest ironChestBlock;

View File

@ -21,14 +21,14 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemChestChanger extends Item public class ItemChestChanger extends Item
{ {
private ChestChangerType type; private ChestChangerType type;
public ItemChestChanger(ChestChangerType type) public ItemChestChanger(ChestChangerType type)
{ {
this.type = type; this.type = type;
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setUnlocalizedName("ironchest:" + type.name()); this.setUnlocalizedName("ironchest:" + type.name());
this.setCreativeTab(CreativeTabs.tabMisc); this.setCreativeTab(CreativeTabs.tabMisc);
@ -40,13 +40,13 @@ public class ItemChestChanger extends Item
if (world.isRemote) if (world.isRemote)
return false; return false;
if(this.type.canUpgrade(IronChestType.WOOD)){ if(this.type.canUpgrade(IronChestType.WOOD)){
if(!(world.getBlockState(pos).getBlock() instanceof BlockChest)){ if(!(world.getBlockState(pos).getBlock() instanceof BlockChest)){
return false; return false;
} }
}else{ }else{
if(world.getBlockState(pos) != IronChest.ironChestBlock.getStateFromMeta(IronChestType.valueOf(type.getSource().getName().toUpperCase()).ordinal())){ if(world.getBlockState(pos) != IronChest.ironChestBlock.getStateFromMeta(IronChestType.valueOf(type.getSource().getName().toUpperCase()).ordinal())){
return false; return false;
} }
} }
TileEntity te = world.getTileEntity(pos); TileEntity te = world.getTileEntity(pos);
TileEntityIronChest newchest = new TileEntityIronChest(); TileEntityIronChest newchest = new TileEntityIronChest();

View File

@ -9,14 +9,13 @@ import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class OcelotsSitOnChestsHandler { public class OcelotsSitOnChestsHandler {
@SubscribeEvent @SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt) public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt)
{ {
if (evt.entityLiving.ticksExisted < 5 && evt.entityLiving instanceof EntityOcelot) if (evt.entityLiving.ticksExisted < 5 && evt.entityLiving instanceof EntityOcelot)
{ {
EntityOcelot ocelot = (EntityOcelot) evt.entityLiving; EntityOcelot ocelot = (EntityOcelot) evt.entityLiving;
@SuppressWarnings("unchecked")
List<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries; List<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries;
for (EntityAITasks.EntityAITaskEntry task : tasks) { for (EntityAITasks.EntityAITaskEntry task : tasks) {

View File

@ -316,7 +316,6 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
{ {
this.numUsingPlayers = 0; this.numUsingPlayers = 0;
float var1 = 5.0F; float var1 = 5.0F;
@SuppressWarnings("unchecked")
List<EntityPlayer> var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() - var1, pos.getY() - var1, pos.getZ() - var1, pos.getX() + 1 + var1, pos.getY() + 1 + var1, pos.getZ() + 1 + var1)); List<EntityPlayer> var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() - var1, pos.getY() - var1, pos.getZ() - var1, pos.getX() + 1 + var1, pos.getY() + 1 + var1, pos.getZ() + 1 + var1));
for (EntityPlayer var4 : var2) for (EntityPlayer var4 : var2)
@ -438,7 +437,7 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
} }
@Override @Override
public Packet getDescriptionPacket() public Packet<?> getDescriptionPacket()
{ {
NBTTagCompound nbt = new NBTTagCompound(); NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("type", getType().ordinal()); nbt.setInteger("type", getType().ordinal());

View File

@ -13,17 +13,6 @@ package cpw.mods.ironchest.client;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.SignedBytes; import com.google.common.primitives.SignedBytes;
@ -32,8 +21,17 @@ import cpw.mods.ironchest.BlockIronChest;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileEntityIronChest>
{ {
private static Map<IronChestType, ResourceLocation> locations; private static Map<IronChestType, ResourceLocation> locations;
@ -44,14 +42,14 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
} }
locations = builder.build(); locations = builder.build();
} }
private Random random; private Random random;
private RenderEntityItem itemRenderer; private RenderEntityItem itemRenderer;
private ModelChest model; private ModelChest model;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F },
{ 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, }; { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
public TileEntityIronChestRenderer() public TileEntityIronChestRenderer()
{ {
model = new ModelChest(); model = new ModelChest();
@ -79,14 +77,14 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
} }
int facing = 3; int facing = 3;
IronChestType type = tile.getType(); IronChestType type = tile.getType();
if (tile != null && tile.hasWorldObj() && tile.getWorld().getBlockState(tile.getPos()).getBlock() == IronChest.ironChestBlock) { if (tile != null && tile.hasWorldObj() && tile.getWorld().getBlockState(tile.getPos()).getBlock() == IronChest.ironChestBlock) {
facing = tile.getFacing(); facing = tile.getFacing();
type = tile.getType(); type = tile.getType();
IBlockState state = tile.getWorld().getBlockState(tile.getPos()); IBlockState state = tile.getWorld().getBlockState(tile.getPos());
type = (IronChestType)state.getValue(BlockIronChest.VARIANT_PROP); type = (IronChestType)state.getValue(BlockIronChest.VARIANT_PROP);
} }
if (breakStage >= 0) if (breakStage >= 0)
{ {
bindTexture(DESTROY_STAGES[breakStage]); bindTexture(DESTROY_STAGES[breakStage]);
@ -96,10 +94,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F); GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888); GlStateManager.matrixMode(5888);
} else } else
bindTexture(locations.get(type)); bindTexture(locations.get(type));
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
if(type == IronChestType.CRYSTAL) if(type == IronChestType.CRYSTAL)
GlStateManager.disableCull(); GlStateManager.disableCull();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.translate((float) x, (float) y + 1.0F, (float) z + 1.0F); GlStateManager.translate((float) x, (float) y + 1.0F, (float) z + 1.0F);
GlStateManager.scale(1.0F, -1F, -1F); GlStateManager.scale(1.0F, -1F, -1F);
@ -132,10 +130,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
GlStateManager.matrixMode(5888); GlStateManager.matrixMode(5888);
} }
if(type == IronChestType.CRYSTAL) if(type == IronChestType.CRYSTAL)
GlStateManager.enableCull(); GlStateManager.enableCull();
GlStateManager.popMatrix(); GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (type.isTransparent() && tile.getDistanceSq(this.rendererDispatcher.entityX, this.rendererDispatcher.entityY, this.rendererDispatcher.entityZ) < 128d) { if (type.isTransparent() && tile.getDistanceSq(this.rendererDispatcher.entityX, this.rendererDispatcher.entityY, this.rendererDispatcher.entityZ) < 128d) {
random.setSeed(254L); random.setSeed(254L);
float shiftX; float shiftX;
@ -175,10 +173,9 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} }
} }
@Override public void renderTileEntityAt(TileEntityIronChest tileentity, double x, double y, double z, float partialTick, int breakStage)
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick, int breakStage)
{ {
render((TileEntityIronChest) tileentity, x, y, z, partialTick, breakStage); render(tileentity, x, y, z, partialTick, breakStage);
} }
} }