pile shenanigans

This commit is contained in:
Vaern 2022-04-30 23:07:14 -07:00
parent ef921967c0
commit cc4b0d01c0
14 changed files with 115 additions and 30 deletions

View File

@ -3,12 +3,16 @@ package com.hbm.blocks.machine.pile;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import api.hbm.block.IToolable;
import api.hbm.block.IToolable.ToolType;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockGraphiteDrilled extends BlockGraphiteDrilledBase {
public class BlockGraphiteDrilled extends BlockGraphiteDrilledBase implements IToolable {
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
@ -16,13 +20,17 @@ public class BlockGraphiteDrilled extends BlockGraphiteDrilledBase {
if(player.getHeldItem() != null) {
int meta = world.getBlockMetadata(x, y, z);
if(side == meta * 2 || side == meta * 2 + 1) {
int cfg = meta & 3;
if(side == cfg * 2 || side == cfg * 2 + 1) {
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_uranium, ModBlocks.block_graphite_fuel)) return true;
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_plutonium, ModBlocks.block_graphite_plutonium)) return true;
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_source, ModBlocks.block_graphite_source)) return true;
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_boron, ModBlocks.block_graphite_rod)) return true;
if(checkInteraction(world, x, y, z, 0, player, ModItems.ingot_graphite, ModBlocks.block_graphite)) return true;
if(meta >> 2 != 1) {
if(checkInteraction(world, x, y, z, meta | 4, player, ModItems.hull_small_aluminium, ModBlocks.block_graphite_drilled)) return true;
if(checkInteraction(world, x, y, z, 0, player, ModItems.ingot_graphite, ModBlocks.block_graphite)) return true;
}
}
}
@ -42,4 +50,23 @@ public class BlockGraphiteDrilled extends BlockGraphiteDrilledBase {
return false;
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
int meta = world.getBlockMetadata(x, y, z);
int cfg = meta & 3;
if(tool != ToolType.SCREWDRIVER)
return false;
if(!world.isRemote && (side == cfg * 2 || side == cfg * 2 + 1) && meta >> 2 == 1) {
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, cfg, 3);
world.playSoundEffect(x + 0.5, y + 1.5, z + 0.5, "hbm:item.upgradePlug", 1.0F, 0.85F);
BlockGraphiteRod.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.hull_small_aluminium));
}
return true;
}
}

View File

@ -23,6 +23,8 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable {
@SideOnly(Side.CLIENT)
protected IIcon sideIcon;
@SideOnly(Side.CLIENT)
protected IIcon blockIconAluminum; //shrouded in aluminum
public BlockGraphiteDrilledBase() {
super(ModBlocks.block_graphite.getMaterial(), ((BlockFlammable) ModBlocks.block_graphite).encouragement, ((BlockFlammable) ModBlocks.block_graphite).flammability);
@ -38,6 +40,7 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable {
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.sideIcon = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite");
this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_drilled_aluminum");
}
@Override
@ -45,9 +48,14 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable {
public IIcon getIcon(int side, int metadata) {
int cfg = metadata & 3;
int meta = metadata >> 2;
if(side == cfg * 2 || side == cfg * 2 + 1)
if(side == cfg * 2 || side == cfg * 2 + 1) {
if(meta == 1)
return this.blockIconAluminum;
return this.blockIcon;
}
return this.sideIcon;
}
@ -70,6 +78,8 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable {
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
ArrayList<ItemStack> drops = new ArrayList();
drops.add(new ItemStack(ModItems.ingot_graphite, 8));
if(meta >> 2 == 1)
drops.add(new ItemStack(ModItems.hull_small_aluminium, 1));
return drops;
}
}

View File

@ -4,9 +4,13 @@ import java.util.ArrayList;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.pile.TileEntityPileFuel;
import api.hbm.block.IToolable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -23,6 +27,13 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab
return new TileEntityPileFuel();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_fuel_aluminum");
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drops = super.getDrops(world, x, y, z, metadata, fortune);
@ -37,9 +48,10 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab
if(tool == ToolType.SCREWDRIVER) {
int meta = world.getBlockMetadata(x, y, z) & 3;
int meta = world.getBlockMetadata(x, y, z);
int cfg = meta & 3;
if(side == meta * 2 || side == meta * 2 + 1) {
if(side == cfg * 2 || side == cfg * 2 + 1) {
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta, 3);
this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.pile_rod_uranium));
}

View File

@ -20,12 +20,15 @@ public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToola
@SideOnly(Side.CLIENT)
protected IIcon outIcon;
@SideOnly(Side.CLIENT)
protected IIcon outIconAluminum;
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.sideIcon = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite");
this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_rod_in_aluminum");
this.outIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_rod_out_aluminum");
this.outIcon = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_rod_out");
}
@ -35,8 +38,11 @@ public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToola
int cfg = metadata & 3;
if(side == cfg * 2 || side == cfg * 2 + 1)
return ((metadata & 4) > 0) ? this.outIcon : this.blockIcon;
if(side == cfg * 2 || side == cfg * 2 + 1) {
if((metadata & 4) == 4)
return ((metadata & 8) > 0) ? this.outIconAluminum : this.blockIconAluminum;
return ((metadata & 8) > 0) ? this.outIcon : this.blockIcon;
}
return this.sideIcon;
}
@ -48,7 +54,7 @@ public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToola
return false;
int oldMeta = world.getBlockMetadata(x, y, z);
int newMeta = oldMeta ^ 4; //toggle bit #3
int newMeta = oldMeta ^ 8; //toggle bit #4
int pureMeta = oldMeta & 3; //in case the bit was set
if(side == pureMeta * 2 || side == pureMeta * 2 + 1) {
@ -60,7 +66,7 @@ public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToola
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, pureMeta == oldMeta ? 0.75F : 0.65F);
ForgeDirection dir = ForgeDirection.getOrientation(pureMeta);
ForgeDirection dir = ForgeDirection.getOrientation(side);
if(dir == ForgeDirection.UNKNOWN)
return true;
@ -68,17 +74,19 @@ public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToola
for(int i = -1; i <= 1; i += 1) {
//why is XZ switched? i don't know, man
int ix = x + dir.offsetZ * i;
/* ForgeDirection's getOrientation method operates on actual sides, not n/s or w/e, so you had to switch x & z for w/e to work since it was actually returning north. also meant that
n/s hasn't been working this entire time */
int ix = x + dir.offsetX * i;
int iy = y + dir.offsetY * i;
int iz = z + dir.offsetX * i;
int iz = z + dir.offsetZ * i;
while(world.getBlock(ix, iy, iz) == this && world.getBlockMetadata(ix, iy, iz) == oldMeta) {
world.setBlockMetadataWithNotify(ix, iy, iz, newMeta, 3);
ix += dir.offsetZ * i;
ix += dir.offsetX * i;
iy += dir.offsetY * i;
iz += dir.offsetX * i;
iz += dir.offsetZ * i;
}
}
@ -96,10 +104,11 @@ public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToola
if(!world.isRemote) {
int meta = world.getBlockMetadata(x, y, z) & 3;
int meta = world.getBlockMetadata(x, y, z);
int cfg = meta & 3;
if(side == meta * 2 || side == meta * 2 + 1) {
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta, 3);
if(side == cfg * 2 || side == cfg * 2 + 1) {
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta & 7, 3);
this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.pile_rod_boron));
}
}

View File

@ -4,9 +4,13 @@ import java.util.ArrayList;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.pile.TileEntityPileSource;
import api.hbm.block.IToolable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -21,6 +25,16 @@ public class BlockGraphiteSource extends BlockGraphiteDrilledTE implements ITool
return new TileEntityPileSource();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
if(this == ModBlocks.block_graphite_plutonium)
this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_plutonium_aluminum");
else if(this == ModBlocks.block_graphite_source)
this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_source_aluminum");
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drops = super.getDrops(world, x, y, z, metadata, fortune);
@ -36,9 +50,10 @@ public class BlockGraphiteSource extends BlockGraphiteDrilledTE implements ITool
if(!world.isRemote) {
int meta = world.getBlockMetadata(x, y, z) & 3;
int meta = world.getBlockMetadata(x, y, z);
int cfg = meta & 3;
if(side == meta * 2 || side == meta * 2 + 1) {
if(side == cfg * 2 || side == cfg * 2 + 1) {
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta, 3);
this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(whoAmIAgain()));
}

View File

@ -26,6 +26,7 @@ public abstract class TileEntityPileBase extends TileEntity {
Vec3 vec = Vec3.createVectorHelper(1, 0, 0);
vec.rotateAroundZ((float)(rand.nextDouble() * Math.PI * 2D));
vec.rotateAroundY((float)(rand.nextDouble() * Math.PI * 2D));
vec.rotateAroundX((float)(rand.nextDouble() * Math.PI * 2D));
int prevX = xCoord;
int prevY = yCoord;
@ -44,6 +45,16 @@ public abstract class TileEntityPileBase extends TileEntity {
prevY = y;
prevZ = z;
/*if(i == range) {
NBTTagCompound data2 = new NBTTagCompound();
data2.setString("type", "vanillaExt");
data2.setString("mode", "greendust");
data2.setDouble("posX", xCoord + 0.5 + vec.xCoord * range);
data2.setDouble("posY", yCoord + 0.5 + vec.yCoord * range);
data2.setDouble("posZ", zCoord + 0.5 + vec.zCoord * range);
MainRegistry.proxy.effectNT(data2);
}*/
Block b = worldObj.getBlock(x, y, z);
if(b == ModBlocks.concrete || b == ModBlocks.concrete_smooth || b == ModBlocks.concrete_asbestos || b == ModBlocks.concrete_colored || b == ModBlocks.brick_concrete)
@ -54,19 +65,20 @@ public abstract class TileEntityPileBase extends TileEntity {
int meta = worldObj.getBlockMetadata(x, y, z);
if(b == ModBlocks.block_graphite_rod && (meta & 4) == 0)
if(b == ModBlocks.block_graphite_rod && (meta & 8) == 0)
return;
TileEntity te = worldObj.getTileEntity(x, y, z);
if(te instanceof IPileNeutronReceiver) {
//this part throttles neutron efficiency for reactions that are way too close, efficiency reaches 100% after 2.5 meters
float mult = Math.min((float)range / 1.5F, 1F);
int n = (int)(flux * mult);
//this part throttles neutron efficiency for reactions that are way too close, efficiency reaches 100% after 1.5 meters
//This entire time, this multiplier has been using the max distance, not the actual one, meaning efficency has always been 100%
//float mult = Math.min((float)i / 1.5F, 1F);
//int n = (int)(flux * mult);
IPileNeutronReceiver rec = (IPileNeutronReceiver) te;
rec.receiveNeutrons(n);
rec.receiveNeutrons(flux);
return;
}

View File

@ -34,7 +34,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
}
private void dissipateHeat() {
this.heat -= heat * 0.05; //remove 5% of the stored heat per tick
this.heat -= (this.getBlockMetadata() & 4) == 4 ? heat * 0.065 : heat * 0.05; //remove 5% of the stored heat per tick; 6.5% for windscale
}
private void react() {
@ -42,7 +42,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
int reaction = (int) (this.neutrons * (1D - ((double)this.heat / (double)this.maxHeat) * 0.5D)); //max heat reduces reaction by 50% due to thermal expansion
this.lastNeutrons = this.neutrons;
this.neutrons = 0;;
this.neutrons = 0;
this.progress += reaction;
@ -51,7 +51,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
this.heat += reaction;
for(int i = 0; i < 16; i++)
for(int i = 0; i < 12; i++)
this.castRay((int) Math.max(reaction * 0.25, 1), 5);
}

View File

@ -11,7 +11,7 @@ public class TileEntityPileSource extends TileEntityPileBase {
int n = this.getBlockType() == ModBlocks.block_graphite_source ? 1 : 3;
for(int i = 0; i < 16; i++) {
for(int i = 0; i < 12; i++) {
this.castRay(n, 5);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B