Chicago Pile fix ClassCastException.

This commit is contained in:
BallOfEnergy 2024-12-31 17:18:04 -06:00
parent 86de688469
commit 9a22c343c9
2 changed files with 30 additions and 31 deletions

View File

@ -56,22 +56,22 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
public Item getItemDropped(int i, Random rand, int j) { public Item getItemDropped(int i, Random rand, int j) {
return null; return null;
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
TileEntityBobble entity = (TileEntityBobble) world.getTileEntity(x, y, z); TileEntityBobble entity = (TileEntityBobble) world.getTileEntity(x, y, z);
if(entity != null) { if(entity != null) {
return new ItemStack(this, 1, entity.type.ordinal()); return new ItemStack(this, 1, entity.type.ordinal());
} }
return super.getPickBlock(target, world, x, y, z, player); return super.getPickBlock(target, world, x, y, z, player);
} }
@Override @Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) { public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if(!player.capabilities.isCreativeMode) { if(!player.capabilities.isCreativeMode) {
harvesters.set(player); harvesters.set(player);
if(!world.isRemote) { if(!world.isRemote) {
@ -87,7 +87,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
harvesters.set(null); harvesters.set(null);
} }
} }
@Override @Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) { public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
@ -96,11 +96,11 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) { if(world.isRemote) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true; return true;
} else { } else {
return true; return true;
} }
@ -109,7 +109,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) { public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 1; i < BobbleType.values().length; i++) for(int i = 1; i < BobbleType.values().length; i++)
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
@ -118,12 +118,12 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int meta = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; int meta = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
world.setBlockMetadataWithNotify(x, y, z, meta, 2); world.setBlockMetadataWithNotify(x, y, z, meta, 2);
TileEntityBobble bobble = (TileEntityBobble) world.getTileEntity(x, y, z); TileEntityBobble bobble = (TileEntityBobble) world.getTileEntity(x, y, z);
bobble.type = BobbleType.values()[Math.abs(stack.getItemDamage()) % BobbleType.values().length]; bobble.type = BobbleType.values()[Math.abs(stack.getItemDamage()) % BobbleType.values().length];
bobble.markDirty(); bobble.markDirty();
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F; float f = 0.0625F;
@ -142,7 +142,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
} }
public static class TileEntityBobble extends TileEntity { public static class TileEntityBobble extends TileEntity {
public BobbleType type = BobbleType.NONE; public BobbleType type = BobbleType.NONE;
@Override @Override
@ -156,7 +156,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
this.writeToNBT(nbt); this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
} }
@Override @Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g()); this.readFromNBT(pkt.func_148857_g());
@ -174,9 +174,9 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
nbt.setByte("type", (byte) type.ordinal()); nbt.setByte("type", (byte) type.ordinal());
} }
} }
public static enum BobbleType { public static enum BobbleType {
NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK), NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK),
STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS), STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS),
PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH), PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH),
@ -198,7 +198,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
NOS( "Dr Nostalgia", "Dr Nostalgia", "SSG and Vortex models", "Take a picture, I'ma pose, paparazzi$I've been drinking, moving like a zombie", true, ScrapType.BOARD_TRANSISTOR), NOS( "Dr Nostalgia", "Dr Nostalgia", "SSG and Vortex models", "Take a picture, I'ma pose, paparazzi$I've been drinking, moving like a zombie", true, ScrapType.BOARD_TRANSISTOR),
DRILLGON( "Drillgon200", "Drillgon200", "1.12 Port", null, false, ScrapType.CPU_LOGIC), DRILLGON( "Drillgon200", "Drillgon200", "1.12 Port", null, false, ScrapType.CPU_LOGIC),
CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK), CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK),
MICROWAVE( "Microwave", "Microwave", "OC Compatibility", "they call me the food heater", true, ScrapType.BOARD_CONVERTER), MICROWAVE( "Microwave", "Microwave", "OC Compatibility and massive RBMK/packet optimizations", "they call me the food heater$john optimization", true, ScrapType.BOARD_CONVERTER),
PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD), PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD),
MELLOW( "MELLOWARPEGGIATION", "Mellow", "Industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR); MELLOW( "MELLOWARPEGGIATION", "Mellow", "Industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR);
@ -208,7 +208,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
public String inscription; //the flavor text public String inscription; //the flavor text
public boolean skinLayers; public boolean skinLayers;
public ScrapType scrap; public ScrapType scrap;
private BobbleType(String name, String label, String contribution, String inscription, boolean layers, ScrapType scrap) { private BobbleType(String name, String label, String contribution, String inscription, boolean layers, ScrapType scrap) {
this.name = name; this.name = name;
this.label = label; this.label = label;

View File

@ -74,29 +74,28 @@ public class PileNeutronHandler {
NeutronNodeWorld.addNode(new PileNeutronNode((TileEntityPileBase) tile)); NeutronNodeWorld.addNode(new PileNeutronNode((TileEntityPileBase) tile));
} }
TileEntityPileBase te = (TileEntityPileBase) tile; Block block = tile.getBlockType();
Block block = te.getBlockType(); int meta = tile.getBlockMetadata();
if(!(tile instanceof TileEntityPileBase)) {
// Return when a boron block is hit
if (block == ModBlocks.block_boron)
return;
// Return when a boron block is hit else if (block == ModBlocks.concrete ||
if(block == ModBlocks.block_boron)
return;
else if(block == ModBlocks.concrete ||
block == ModBlocks.concrete_smooth || block == ModBlocks.concrete_smooth ||
block == ModBlocks.concrete_asbestos || block == ModBlocks.concrete_asbestos ||
block == ModBlocks.concrete_colored || block == ModBlocks.concrete_colored ||
block == ModBlocks.brick_concrete) block == ModBlocks.brick_concrete)
fluxQuantity *= 0.25; fluxQuantity *= 0.25;
int meta = te.getBlockMetadata(); if (block == ModBlocks.block_graphite_rod && (meta & 8) == 0)
return;
}
if(block == ModBlocks.block_graphite_rod && (meta & 8) == 0) if(tile instanceof IPileNeutronReceiver) {
return;
if(te instanceof IPileNeutronReceiver) { IPileNeutronReceiver rec = (IPileNeutronReceiver) tile;
IPileNeutronReceiver rec = (IPileNeutronReceiver) te;
rec.receiveNeutrons((int) Math.floor(fluxQuantity)); rec.receiveNeutrons((int) Math.floor(fluxQuantity));
if(block != ModBlocks.block_graphite_detector || (meta & 8) == 0) if(block != ModBlocks.block_graphite_detector || (meta & 8) == 0)