mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-24 05:54:34 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -12,29 +12,25 @@ import tconstruct.mechworks.gui.GuiLandmine;
|
||||
import tconstruct.mechworks.inventory.ContainerLandmine;
|
||||
import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
|
||||
public class MechworksProxyClient extends MechworksProxyCommon
|
||||
{
|
||||
public void initialize ()
|
||||
{
|
||||
public class MechworksProxyClient extends MechworksProxyCommon {
|
||||
public void initialize() {
|
||||
registerRenderer();
|
||||
registerGuiHandler();
|
||||
}
|
||||
|
||||
void registerRenderer ()
|
||||
{
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityLandmineFirework.class, new RenderSnowball(Items.fireworks));
|
||||
void registerRenderer() {
|
||||
RenderingRegistry.registerEntityRenderingHandler(
|
||||
EntityLandmineFirework.class, new RenderSnowball(Items.fireworks));
|
||||
RenderingRegistry.registerEntityRenderingHandler(ExplosivePrimed.class, new ExplosiveRender());
|
||||
}
|
||||
|
||||
protected void registerGuiHandler ()
|
||||
{
|
||||
protected void registerGuiHandler() {
|
||||
super.registerGuiHandler();
|
||||
TProxyCommon.registerClientGuiHandler(landmineID, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == MechworksProxyCommon.landmineID)
|
||||
return new GuiLandmine(new ContainerLandmine(player, (TileEntityLandmine) world.getTileEntity(x, y, z)));
|
||||
return null;
|
||||
|
||||
@@ -7,26 +7,21 @@ import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.mechworks.inventory.ContainerLandmine;
|
||||
import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
|
||||
public class MechworksProxyCommon implements IGuiHandler
|
||||
{
|
||||
public void initialize ()
|
||||
{
|
||||
public class MechworksProxyCommon implements IGuiHandler {
|
||||
public void initialize() {
|
||||
registerGuiHandler();
|
||||
}
|
||||
|
||||
public static int drawbridgeID = 9;
|
||||
public static final int landmineID = 10;
|
||||
|
||||
protected void registerGuiHandler ()
|
||||
{
|
||||
protected void registerGuiHandler() {
|
||||
TProxyCommon.registerServerGuiHandler(landmineID, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (ID == MechworksProxyCommon.landmineID)
|
||||
{
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == MechworksProxyCommon.landmineID) {
|
||||
return new ContainerLandmine(player, (TileEntityLandmine) world.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@@ -34,10 +29,8 @@ public class MechworksProxyCommon implements IGuiHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,43 +18,89 @@ import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
|
||||
@ObjectHolder(TConstruct.modID)
|
||||
//TODO handle migration of all items/blocks that were owned by the previously seperate mod
|
||||
// TODO handle migration of all items/blocks that were owned by the previously seperate mod
|
||||
@Pulse(id = "Tinkers' Mechworks", description = "Mechanical machinations and steampunk inspired shenanigans.")
|
||||
public class TinkerMechworks
|
||||
{
|
||||
@SidedProxy(clientSide = "tconstruct.mechworks.MechworksProxyClient", serverSide = "tconstruct.mechworks.MechworksProxyCommon")
|
||||
public class TinkerMechworks {
|
||||
@SidedProxy(
|
||||
clientSide = "tconstruct.mechworks.MechworksProxyClient",
|
||||
serverSide = "tconstruct.mechworks.MechworksProxyCommon")
|
||||
public static MechworksProxyCommon proxy;
|
||||
// Traps
|
||||
public static Block landmine;
|
||||
|
||||
@Handler
|
||||
public void preInit (FMLPreInitializationEvent event)
|
||||
{
|
||||
//NetworkRegistry.INSTANCE.registerGuiHandler(TConstruct.instance, proxy);
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
// NetworkRegistry.INSTANCE.registerGuiHandler(TConstruct.instance, proxy);
|
||||
// Traps
|
||||
TinkerMechworks.landmine = new BlockLandmine().setHardness(0.5F).setResistance(0F).setStepSound(Block.soundTypeMetal).setCreativeTab(CreativeTabs.tabRedstone).setBlockName("landmine");
|
||||
TinkerMechworks.landmine = new BlockLandmine()
|
||||
.setHardness(0.5F)
|
||||
.setResistance(0F)
|
||||
.setStepSound(Block.soundTypeMetal)
|
||||
.setCreativeTab(CreativeTabs.tabRedstone)
|
||||
.setBlockName("landmine");
|
||||
GameRegistry.registerBlock(TinkerMechworks.landmine, ItemBlockLandmine.class, "Redstone.Landmine");
|
||||
GameRegistry.registerTileEntity(TileEntityLandmine.class, "Landmine");
|
||||
|
||||
// Landmine Recipes
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerMechworks.landmine, 1, 0), "mcm", "rpr", 'm', "plankWood", 'c', new ItemStack(TinkerTools.blankPattern, 1, 1), 'r', "dustRedstone", 'p', Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerMechworks.landmine, 1, 1), "mcm", "rpr", 'm', Blocks.stone, 'c', new ItemStack(TinkerTools.blankPattern, 1, 1), 'r', "dustRedstone", 'p', Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerMechworks.landmine, 1, 2), "mcm", "rpr", 'm', Blocks.obsidian, 'c', new ItemStack(TinkerTools.blankPattern, 1, 1), 'r', "dustRedstone", 'p', Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerMechworks.landmine, 1, 3), "mcm", "rpr", 'm', Items.repeater, 'c', new ItemStack(TinkerTools.blankPattern, 1, 1), 'r', "dustRedstone", 'p', Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
new ItemStack(TinkerMechworks.landmine, 1, 0),
|
||||
"mcm",
|
||||
"rpr",
|
||||
'm',
|
||||
"plankWood",
|
||||
'c',
|
||||
new ItemStack(TinkerTools.blankPattern, 1, 1),
|
||||
'r',
|
||||
"dustRedstone",
|
||||
'p',
|
||||
Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
new ItemStack(TinkerMechworks.landmine, 1, 1),
|
||||
"mcm",
|
||||
"rpr",
|
||||
'm',
|
||||
Blocks.stone,
|
||||
'c',
|
||||
new ItemStack(TinkerTools.blankPattern, 1, 1),
|
||||
'r',
|
||||
"dustRedstone",
|
||||
'p',
|
||||
Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
new ItemStack(TinkerMechworks.landmine, 1, 2),
|
||||
"mcm",
|
||||
"rpr",
|
||||
'm',
|
||||
Blocks.obsidian,
|
||||
'c',
|
||||
new ItemStack(TinkerTools.blankPattern, 1, 1),
|
||||
'r',
|
||||
"dustRedstone",
|
||||
'p',
|
||||
Blocks.stone_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
new ItemStack(TinkerMechworks.landmine, 1, 3),
|
||||
"mcm",
|
||||
"rpr",
|
||||
'm',
|
||||
Items.repeater,
|
||||
'c',
|
||||
new ItemStack(TinkerTools.blankPattern, 1, 1),
|
||||
'r',
|
||||
"dustRedstone",
|
||||
'p',
|
||||
Blocks.stone_pressure_plate));
|
||||
|
||||
EntityRegistry.registerModEntity(EntityLandmineFirework.class, "LandmineFirework", 5, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(
|
||||
EntityLandmineFirework.class, "LandmineFirework", 5, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(ExplosivePrimed.class, "SlimeExplosive", 6, TConstruct.instance, 32, 5, true);
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void init (FMLInitializationEvent event)
|
||||
{
|
||||
public void init(FMLInitializationEvent event) {
|
||||
proxy.initialize();
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void postInit (FMLPostInitializationEvent evt)
|
||||
{
|
||||
|
||||
}
|
||||
public void postInit(FMLPostInitializationEvent evt) {}
|
||||
}
|
||||
@@ -2,12 +2,11 @@ package tconstruct.mechworks.blocks;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.*;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -41,35 +40,29 @@ import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
import tconstruct.world.model.RenderLandmine;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BlockLandmine extends BlockContainer
|
||||
{
|
||||
public class BlockLandmine extends BlockContainer {
|
||||
|
||||
// Should explode when broken instead of dropping items(may not actually
|
||||
// work
|
||||
boolean explodeOnBroken = false;
|
||||
|
||||
public BlockLandmine()
|
||||
{
|
||||
public BlockLandmine() {
|
||||
super(Material.tnt);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if (world.getBlock(x, y, z) == (Block) this && world.getTileEntity(x, y, z) instanceof TileEntityLandmine)
|
||||
{
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z) == (Block) this && world.getTileEntity(x, y, z) instanceof TileEntityLandmine) {
|
||||
TileEntityLandmine te = (TileEntityLandmine) world.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null)
|
||||
{
|
||||
if (te.getStackInSlot(3) != null && te.getStackInSlot(3).getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (te != null) {
|
||||
if (te.getStackInSlot(3) != null && te.getStackInSlot(3).getItem() instanceof ItemBlock) {
|
||||
return (BlockUtils.getBlockFromItem(te.getStackInSlot(3).getItem())).getLightValue();
|
||||
}
|
||||
}
|
||||
@@ -78,105 +71,104 @@ public class BlockLandmine extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate (World par1World)
|
||||
{
|
||||
public int tickRate(World par1World) {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
public IIcon getIcon(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1IBlockAccess.getTileEntity(par2, par3, par4);
|
||||
|
||||
ItemStack camo = te.getStackInSlot(3);
|
||||
if (camo != null)
|
||||
{
|
||||
if (camo != null) {
|
||||
return BlockUtils.getBlockFromItem(camo.getItem()).getIcon(par5, camo.getItemDamage());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return this.getIcon(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
public int getRenderType() {
|
||||
return RenderLandmine.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {
|
||||
super.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer);
|
||||
|
||||
if (this.explodeOnBroken)
|
||||
{
|
||||
if (this.explodeOnBroken) {
|
||||
checkExplosion(par1World, par2, par3, par4, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:Landmine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
public boolean onBlockActivated(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
EntityPlayer par5EntityPlayer,
|
||||
int par6,
|
||||
float par7,
|
||||
float par8,
|
||||
float par9) {
|
||||
par5EntityPlayer.openGui(TConstruct.instance, MechworksProxyCommon.landmineID, par1World, par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int par2, int par3, int par4, Block par5Block, int par6)
|
||||
{
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5Block, int par6) {
|
||||
TileEntityLandmine tileentity = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
int metadata = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (tileentity != null && (!explodeOnBroken || !hasItems(par1World, par2, par3, par4)) && par6 != 193 && !tileentity.isExploding)
|
||||
{
|
||||
if (this != null)
|
||||
{
|
||||
if (tileentity != null
|
||||
&& (!explodeOnBroken || !hasItems(par1World, par2, par3, par4))
|
||||
&& par6 != 193
|
||||
&& !tileentity.isExploding) {
|
||||
if (this != null) {
|
||||
ItemStack is = new ItemStack(this, 1, damageDropped(tileentity.triggerType));
|
||||
if (tileentity.hasCustomInventoryName())
|
||||
{
|
||||
if (tileentity.hasCustomInventoryName()) {
|
||||
is.setStackDisplayName(tileentity.getInventoryName());
|
||||
}
|
||||
dropBlockAsItem(par1World, par2, par3, par4, new ItemStack(this, 1, damageDropped(tileentity.triggerType)));
|
||||
dropBlockAsItem(
|
||||
par1World, par2, par3, par4, new ItemStack(this, 1, damageDropped(tileentity.triggerType)));
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < tileentity.getSizeInventory(); ++j1)
|
||||
{
|
||||
for (int j1 = 0; j1 < tileentity.getSizeInventory(); ++j1) {
|
||||
ItemStack itemstack = tileentity.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
while (itemstack.stackSize > 0) {
|
||||
|
||||
int ss = itemstack.stackSize;
|
||||
itemstack.stackSize -= ss;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) ((float) par2), (double) ((float) par3), (double) ((float) par4), new ItemStack(itemstack.getItem(), ss, itemstack.getItemDamage()));
|
||||
EntityItem entityitem = new EntityItem(
|
||||
par1World,
|
||||
(double) ((float) par2),
|
||||
(double) ((float) par3),
|
||||
(double) ((float) par4),
|
||||
new ItemStack(itemstack.getItem(), ss, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
if (itemstack.hasTagCompound()) {
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)
|
||||
itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
@@ -189,9 +181,7 @@ public class BlockLandmine extends BlockContainer
|
||||
}
|
||||
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
else if (explodeOnBroken)
|
||||
{
|
||||
} else if (explodeOnBroken) {
|
||||
checkExplosion(par1World, par2, par3, par4, true);
|
||||
}
|
||||
|
||||
@@ -199,8 +189,7 @@ public class BlockLandmine extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
@@ -208,58 +197,59 @@ public class BlockLandmine extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(par5);
|
||||
return (dir == DOWN && par1World.isSideSolid(par2, par3 + 1, par4, DOWN)) || (dir == UP && par1World.isSideSolid(par2, par3 - 1, par4, UP)) || (dir == NORTH && par1World.isSideSolid(par2, par3, par4 + 1, NORTH)) || (dir == SOUTH && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH)) || (dir == WEST && par1World.isSideSolid(par2 + 1, par3, par4, WEST)) || (dir == EAST && par1World.isSideSolid(par2 - 1, par3, par4, EAST));
|
||||
return (dir == DOWN && par1World.isSideSolid(par2, par3 + 1, par4, DOWN))
|
||||
|| (dir == UP && par1World.isSideSolid(par2, par3 - 1, par4, UP))
|
||||
|| (dir == NORTH && par1World.isSideSolid(par2, par3, par4 + 1, NORTH))
|
||||
|| (dir == SOUTH && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH))
|
||||
|| (dir == WEST && par1World.isSideSolid(par2 + 1, par3, par4, WEST))
|
||||
|| (dir == EAST && par1World.isSideSolid(par2 - 1, par3, par4, EAST));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.isSideSolid(par2 - 1, par3, par4, EAST) || par1World.isSideSolid(par2 + 1, par3, par4, WEST) || par1World.isSideSolid(par2, par3, par4 - 1, SOUTH) || par1World.isSideSolid(par2, par3, par4 + 1, NORTH) || par1World.isSideSolid(par2, par3 - 1, par4, UP) || par1World.isSideSolid(par2, par3 + 1, par4, DOWN);
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
|
||||
return par1World.isSideSolid(par2 - 1, par3, par4, EAST)
|
||||
|| par1World.isSideSolid(par2 + 1, par3, par4, WEST)
|
||||
|| par1World.isSideSolid(par2, par3, par4 - 1, SOUTH)
|
||||
|| par1World.isSideSolid(par2, par3, par4 + 1, NORTH)
|
||||
|| par1World.isSideSolid(par2, par3 - 1, par4, UP)
|
||||
|| par1World.isSideSolid(par2, par3 + 1, par4, DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
public int onBlockPlaced(
|
||||
World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) {
|
||||
int j1 = par9 & 8;
|
||||
int k1 = par9 & 7;
|
||||
byte b0 = -1;
|
||||
|
||||
if (par5 == 0 && par1World.isSideSolid(par2, par3 + 1, par4, DOWN))
|
||||
{
|
||||
if (par5 == 0 && par1World.isSideSolid(par2, par3 + 1, par4, DOWN)) {
|
||||
b0 = 0;
|
||||
}
|
||||
|
||||
if (par5 == 1 && par1World.isSideSolid(par2, par3 - 1, par4, UP))
|
||||
{
|
||||
if (par5 == 1 && par1World.isSideSolid(par2, par3 - 1, par4, UP)) {
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
if (par5 == 2 && par1World.isSideSolid(par2, par3, par4 + 1, NORTH))
|
||||
{
|
||||
if (par5 == 2 && par1World.isSideSolid(par2, par3, par4 + 1, NORTH)) {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
if (par5 == 3 && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH))
|
||||
{
|
||||
if (par5 == 3 && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH)) {
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
if (par5 == 4 && par1World.isSideSolid(par2 + 1, par3, par4, WEST))
|
||||
{
|
||||
if (par5 == 4 && par1World.isSideSolid(par2 + 1, par3, par4, WEST)) {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (par5 == 5 && par1World.isSideSolid(par2 - 1, par3, par4, EAST))
|
||||
{
|
||||
if (par5 == 5 && par1World.isSideSolid(par2 - 1, par3, par4, EAST)) {
|
||||
b0 = 1;
|
||||
}
|
||||
|
||||
@@ -267,251 +257,220 @@ public class BlockLandmine extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
public void onBlockPlacedBy(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
EntityLivingBase par5EntityLivingBase,
|
||||
ItemStack par6ItemStack) {
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
int j1 = l & 8;
|
||||
|
||||
if (i1 == invertMetadata(1))
|
||||
{
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0)
|
||||
{
|
||||
if (i1 == invertMetadata(1)) {
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1)
|
||||
== 0) {
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 5 | j1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 6 | j1, 2);
|
||||
}
|
||||
}
|
||||
else if (i1 == invertMetadata(0))
|
||||
{
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0)
|
||||
{
|
||||
} else if (i1 == invertMetadata(0)) {
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1)
|
||||
== 0) {
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7 | j1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | j1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityLandmine) par1World.getTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());
|
||||
if (par6ItemStack.hasDisplayName()) {
|
||||
((TileEntityLandmine) par1World.getTileEntity(par2, par3, par4))
|
||||
.setGuiDisplayName(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
public static int invertMetadata (int par0)
|
||||
{
|
||||
switch (par0)
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 5;
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 3;
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
public static int invertMetadata(int par0) {
|
||||
switch (par0) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 5;
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 3;
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, Block par5Block)
|
||||
{
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5Block) {
|
||||
checkPlacement(par1World, par2, par3, par4, par5Block);
|
||||
|
||||
checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
public void checkPlacement (World par1World, int par2, int par3, int par4, Block par5Block)
|
||||
{
|
||||
if (this.checkIfAttachedToBlock(par1World, par2, par3, par4))
|
||||
{
|
||||
public void checkPlacement(World par1World, int par2, int par3, int par4, Block par5Block) {
|
||||
if (this.checkIfAttachedToBlock(par1World, par2, par3, par4)) {
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
boolean flag = false;
|
||||
|
||||
if (!par1World.isSideSolid(par2 - 1, par3, par4, EAST) && i1 == 1)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2 - 1, par3, par4, EAST) && i1 == 1) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2 + 1, par3, par4, WEST) && i1 == 2)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2 + 1, par3, par4, WEST) && i1 == 2) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 - 1, SOUTH) && i1 == 3)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3, par4 - 1, SOUTH) && i1 == 3) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 + 1, NORTH) && i1 == 4)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3, par4 + 1, NORTH) && i1 == 4) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 - 1, par4, UP) && i1 == 5)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3 - 1, par4, UP) && i1 == 5) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 - 1, par4, UP) && i1 == 6)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3 - 1, par4, UP) && i1 == 6) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 + 1, par4, DOWN) && i1 == 0)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3 + 1, par4, DOWN) && i1 == 0) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 + 1, par4, DOWN) && i1 == 7)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3 + 1, par4, DOWN) && i1 == 7) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIfAttachedToBlock (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
private boolean checkIfAttachedToBlock(World par1World, int par2, int par3, int par4) {
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) {
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
if (!par1World.isRemote) {
|
||||
checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
|
||||
if (!par1World.isRemote) {
|
||||
this.checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkExplosion (World par1World, int par2, int par3, int par4, boolean skipCheck)
|
||||
{
|
||||
if (skipCheck || getMineState(par1World, par2, par3, par4) > 0)
|
||||
{
|
||||
if (hasItems(par1World, par2, par3, par4))
|
||||
{
|
||||
public void checkExplosion(World par1World, int par2, int par3, int par4, boolean skipCheck) {
|
||||
if (skipCheck || getMineState(par1World, par2, par3, par4) > 0) {
|
||||
if (hasItems(par1World, par2, par3, par4)) {
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
if (te.soundcountything <= 0)
|
||||
{
|
||||
par1World.playSoundEffect((double) par2 + 0.5D, (double) par3 + 0.1D, (double) par4 + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
if (te.soundcountything <= 0) {
|
||||
par1World.playSoundEffect(
|
||||
(double) par2 + 0.5D,
|
||||
(double) par3 + 0.1D,
|
||||
(double) par4 + 0.5D,
|
||||
"random.click",
|
||||
0.3F,
|
||||
0.6F);
|
||||
te.setSoundPlayed();
|
||||
}
|
||||
new LandmineExplodeLogic(par1World, par2, par3, par4, getMineTriggerer(par1World, par2, par3, par4)).explode();
|
||||
new LandmineExplodeLogic(par1World, par2, par3, par4, getMineTriggerer(par1World, par2, par3, par4))
|
||||
.explode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasItems (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
private boolean hasItems(World par1World, int par2, int par3, int par4) {
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
if (te != null && te.getStackInSlot(0) != null || te.getStackInSlot(1) != null || te.getStackInSlot(2) != null)
|
||||
{
|
||||
if (te != null && te.getStackInSlot(0) != null
|
||||
|| te.getStackInSlot(1) != null
|
||||
|| te.getStackInSlot(2) != null) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getMineState (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
protected int getMineState(World par1World, int par2, int par3, int par4) {
|
||||
TileEntity tileEntity = par1World.getTileEntity(par2, par3, par4);
|
||||
// Change to return 1 if you want the landmine to blow up when the block
|
||||
// holding it is broken
|
||||
if (!(tileEntity instanceof TileEntityLandmine))
|
||||
{
|
||||
if (!(tileEntity instanceof TileEntityLandmine)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine)tileEntity;
|
||||
TileEntityLandmine te = (TileEntityLandmine) tileEntity;
|
||||
Sensitivity triggerType;
|
||||
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
triggerType = Sensitivity.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerType = Sensitivity.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerType = Sensitivity.players;
|
||||
break;
|
||||
default:
|
||||
triggerType = null;
|
||||
break;
|
||||
switch (te.triggerType) {
|
||||
case 0:
|
||||
triggerType = Sensitivity.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerType = Sensitivity.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerType = Sensitivity.players;
|
||||
break;
|
||||
default:
|
||||
triggerType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triggerType != null)
|
||||
{
|
||||
if (triggerType != null) {
|
||||
List list = null;
|
||||
|
||||
if (triggerType == Sensitivity.everything)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity((Entity) null, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
if (triggerType == Sensitivity.everything) {
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity(
|
||||
(Entity) null, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.mobs)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
if (triggerType == Sensitivity.mobs) {
|
||||
list = par1World.getEntitiesWithinAABB(
|
||||
EntityLivingBase.class, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.players)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(par1World, par2, par3, par4));
|
||||
if (triggerType == Sensitivity.players) {
|
||||
list = par1World.getEntitiesWithinAABB(
|
||||
EntityPlayer.class, this.getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!entity.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
if (!entity.doesEntityNotTriggerPressurePlate()) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -521,8 +480,7 @@ public class BlockLandmine extends BlockContainer
|
||||
return par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) ? 1 : 0;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB getSensitiveAABB (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
protected AxisAlignedBB getSensitiveAABB(World par1World, int par2, int par3, int par4) {
|
||||
float f = 0.125F;
|
||||
// return AxisAlignedBB.getBoundingBox((double)((float)par1 + f),
|
||||
// (double)par2, (double)((float)par3 + f), (double)((float)(par1 + 1) -
|
||||
@@ -532,30 +490,33 @@ public class BlockLandmine extends BlockContainer
|
||||
int i1 = l & 7;
|
||||
boolean flag = (l & 8) > 0;
|
||||
|
||||
float minX = par2 + f, minY = par3, minZ = par4 + f, maxX = par2 + 1 - f, maxY = par3 + 0.25F, maxZ = par4 + 1 - f;
|
||||
float minX = par2 + f,
|
||||
minY = par3,
|
||||
minZ = par4 + f,
|
||||
maxX = par2 + 1 - f,
|
||||
maxY = par3 + 0.25F,
|
||||
maxZ = par4 + 1 - f;
|
||||
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(i1);
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
break;
|
||||
case UP:
|
||||
minY = par3 + 0.75F;
|
||||
maxY = par3 + 1;
|
||||
break;
|
||||
default:
|
||||
minX = par2;
|
||||
minY = par3;
|
||||
minZ = par4;
|
||||
maxX = par2 + 1;
|
||||
maxY = par3 + 1;
|
||||
maxZ = par4 + 1;
|
||||
switch (dir) {
|
||||
case DOWN:
|
||||
break;
|
||||
case UP:
|
||||
minY = par3 + 0.75F;
|
||||
maxY = par3 + 1;
|
||||
break;
|
||||
default:
|
||||
minX = par2;
|
||||
minY = par3;
|
||||
minZ = par4;
|
||||
maxX = par2 + 1;
|
||||
maxY = par3 + 1;
|
||||
maxZ = par4 + 1;
|
||||
}
|
||||
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public Entity getMineTriggerer (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
public Entity getMineTriggerer(World par1World, int par2, int par3, int par4) {
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
@@ -563,55 +524,52 @@ public class BlockLandmine extends BlockContainer
|
||||
|
||||
// Change to return 1 if you want the landmine to blow up when the
|
||||
// block holding it is broken
|
||||
if (te == null)
|
||||
{
|
||||
if (te == null) {
|
||||
return null;
|
||||
}
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
triggerType = Sensitivity.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerType = Sensitivity.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerType = Sensitivity.players;
|
||||
break;
|
||||
default:
|
||||
triggerType = null;
|
||||
break;
|
||||
switch (te.triggerType) {
|
||||
case 0:
|
||||
triggerType = Sensitivity.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerType = Sensitivity.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerType = Sensitivity.players;
|
||||
break;
|
||||
default:
|
||||
triggerType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triggerType != null)
|
||||
{
|
||||
if (triggerType != null) {
|
||||
List list = null;
|
||||
|
||||
if (triggerType == Sensitivity.everything)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity((Entity) null, AxisAlignedBB.getBoundingBox(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
if (triggerType == Sensitivity.everything) {
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity(
|
||||
(Entity) null,
|
||||
AxisAlignedBB.getBoundingBox(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.mobs)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
if (triggerType == Sensitivity.mobs) {
|
||||
list = par1World.getEntitiesWithinAABB(
|
||||
EntityLivingBase.class,
|
||||
AxisAlignedBB.getBoundingBox(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.players)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
if (triggerType == Sensitivity.players) {
|
||||
list = par1World.getEntitiesWithinAABB(
|
||||
EntityPlayer.class,
|
||||
AxisAlignedBB.getBoundingBox(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!entity.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
if (!entity.doesEntityNotTriggerPressurePlate()) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -622,60 +580,54 @@ public class BlockLandmine extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion (Explosion par1Explosion)
|
||||
{
|
||||
public boolean canDropFromExplosion(Explosion par1Explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
boolean flag = (l & 8) > 0;
|
||||
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(i1);
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case UP:
|
||||
this.setBlockBounds(0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case NORTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 0.0F, 1.0F - 0.0625F, 1.0F - 0.0625F, 0.0625F);
|
||||
break;
|
||||
case SOUTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F);
|
||||
break;
|
||||
case EAST:
|
||||
this.setBlockBounds(1.0F - 0.0625F, 0.0625F, 0.0625F, 1.0F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case WEST:
|
||||
this.setBlockBounds(0.0F, 0.0625F, 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
default:
|
||||
this.setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
break;
|
||||
switch (dir) {
|
||||
case DOWN:
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case UP:
|
||||
this.setBlockBounds(0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case NORTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 0.0F, 1.0F - 0.0625F, 1.0F - 0.0625F, 0.0625F);
|
||||
break;
|
||||
case SOUTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F);
|
||||
break;
|
||||
case EAST:
|
||||
this.setBlockBounds(1.0F - 0.0625F, 0.0625F, 0.0625F, 1.0F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case WEST:
|
||||
this.setBlockBounds(0.0F, 0.0625F, 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
default:
|
||||
this.setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
public int damageDropped(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int meta)
|
||||
{
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityLandmine();
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.util.DamageSourceFireworkExplode;
|
||||
|
||||
public class EntityLandmineFirework extends Entity
|
||||
{
|
||||
public class EntityLandmineFirework extends Entity {
|
||||
/** The age of the firework in ticks. */
|
||||
private int fireworkAge;
|
||||
|
||||
@@ -23,20 +22,17 @@ public class EntityLandmineFirework extends Entity
|
||||
|
||||
private int moveDirection = 0;
|
||||
|
||||
public EntityLandmineFirework(World par1World)
|
||||
{
|
||||
public EntityLandmineFirework(World par1World) {
|
||||
super(par1World);
|
||||
this.setSize(0.25F, 0.25F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit ()
|
||||
{
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObjectByDataType(8, 5);
|
||||
}
|
||||
|
||||
public EntityLandmineFirework setRider (Entity entity)
|
||||
{
|
||||
public EntityLandmineFirework setRider(Entity entity) {
|
||||
rider = entity;
|
||||
return this;
|
||||
}
|
||||
@@ -47,13 +43,12 @@ public class EntityLandmineFirework extends Entity
|
||||
* Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
|
||||
* length * 64 * renderDistanceWeight Args: distance
|
||||
*/
|
||||
public boolean isInRangeToRenderDist (double par1)
|
||||
{
|
||||
public boolean isInRangeToRenderDist(double par1) {
|
||||
return par1 < 4096.0D;
|
||||
}
|
||||
|
||||
public EntityLandmineFirework(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack, int moveDirection)
|
||||
{
|
||||
public EntityLandmineFirework(
|
||||
World par1World, double par2, double par4, double par6, ItemStack par8ItemStack, int moveDirection) {
|
||||
super(par1World);
|
||||
this.fireworkAge = 0;
|
||||
this.setSize(0.25F, 0.25F);
|
||||
@@ -61,14 +56,12 @@ public class EntityLandmineFirework extends Entity
|
||||
this.yOffset = 0.0F;
|
||||
int i = 1;
|
||||
|
||||
if (par8ItemStack != null && par8ItemStack.hasTagCompound())
|
||||
{
|
||||
if (par8ItemStack != null && par8ItemStack.hasTagCompound()) {
|
||||
this.dataWatcher.updateObject(8, par8ItemStack);
|
||||
NBTTagCompound nbttagcompound = par8ItemStack.getTagCompound();
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Fireworks");
|
||||
|
||||
if (nbttagcompound1 != null)
|
||||
{
|
||||
if (nbttagcompound1 != null) {
|
||||
i += nbttagcompound1.getByte("Flight");
|
||||
}
|
||||
}
|
||||
@@ -85,14 +78,12 @@ public class EntityLandmineFirework extends Entity
|
||||
/**
|
||||
* Sets the velocity to the args. Args: x, y, z
|
||||
*/
|
||||
public void setVelocity (double par1, double par3, double par5)
|
||||
{
|
||||
public void setVelocity(double par1, double par3, double par5) {
|
||||
this.motionX = par1;
|
||||
this.motionY = par3;
|
||||
this.motionZ = par5;
|
||||
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
|
||||
{
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||
float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
|
||||
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, (double) f) * 180.0D / Math.PI);
|
||||
@@ -103,10 +94,8 @@ public class EntityLandmineFirework extends Entity
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate ()
|
||||
{
|
||||
if (this.riddenByEntity == null && this.rider != null)
|
||||
{
|
||||
public void onUpdate() {
|
||||
if (this.riddenByEntity == null && this.rider != null) {
|
||||
this.rider.mountEntity(this);
|
||||
}
|
||||
|
||||
@@ -121,43 +110,45 @@ public class EntityLandmineFirework extends Entity
|
||||
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
|
||||
{
|
||||
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
|
||||
this.rotationPitch - this.prevRotationPitch < -180.0F;
|
||||
this.prevRotationPitch -= 360.0F) {
|
||||
;
|
||||
}
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
||||
{
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
||||
{
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
||||
{
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
|
||||
if (this.fireworkAge == 0)
|
||||
{
|
||||
if (this.fireworkAge == 0) {
|
||||
this.worldObj.playSoundAtEntity(this, "fireworks.launch", 3.0F, 1.0F);
|
||||
}
|
||||
|
||||
++this.fireworkAge;
|
||||
|
||||
if (this.worldObj.isRemote && this.fireworkAge % 2 < 2)
|
||||
{
|
||||
this.worldObj.spawnParticle("fireworksSpark", this.posX, this.posY - 0.3D, this.posZ, this.rand.nextGaussian() * 0.05D, -this.motionY * 0.5D, this.rand.nextGaussian() * 0.05D);
|
||||
if (this.worldObj.isRemote && this.fireworkAge % 2 < 2) {
|
||||
this.worldObj.spawnParticle(
|
||||
"fireworksSpark",
|
||||
this.posX,
|
||||
this.posY - 0.3D,
|
||||
this.posZ,
|
||||
this.rand.nextGaussian() * 0.05D,
|
||||
-this.motionY * 0.5D,
|
||||
this.rand.nextGaussian() * 0.05D);
|
||||
}
|
||||
|
||||
if (!this.worldObj.isRemote && this.fireworkAge > this.lifetime)
|
||||
{
|
||||
if (!this.worldObj.isRemote && this.fireworkAge > this.lifetime) {
|
||||
this.worldObj.setEntityState(this, (byte) 17);
|
||||
this.rider.attackEntityFrom(new DamageSourceFireworkExplode("FireworkExplode"), 200F);
|
||||
this.setDead();
|
||||
@@ -166,19 +157,17 @@ public class EntityLandmineFirework extends Entity
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleHealthUpdate (byte par1)
|
||||
{
|
||||
if (par1 == 17 && this.worldObj.isRemote)
|
||||
{
|
||||
public void handleHealthUpdate(byte par1) {
|
||||
if (par1 == 17 && this.worldObj.isRemote) {
|
||||
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
|
||||
NBTTagCompound nbttagcompound = null;
|
||||
|
||||
if (itemstack != null && itemstack.hasTagCompound())
|
||||
{
|
||||
if (itemstack != null && itemstack.hasTagCompound()) {
|
||||
nbttagcompound = itemstack.getTagCompound().getCompoundTag("Fireworks");
|
||||
}
|
||||
|
||||
this.worldObj.makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
|
||||
this.worldObj.makeFireworks(
|
||||
this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
|
||||
}
|
||||
|
||||
super.handleHealthUpdate(par1);
|
||||
@@ -188,14 +177,12 @@ public class EntityLandmineFirework extends Entity
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
par1NBTTagCompound.setInteger("Life", this.fireworkAge);
|
||||
par1NBTTagCompound.setInteger("LifeTime", this.lifetime);
|
||||
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
itemstack.writeToNBT(nbttagcompound1);
|
||||
par1NBTTagCompound.setTag("FireworksItem", nbttagcompound1);
|
||||
@@ -206,18 +193,15 @@ public class EntityLandmineFirework extends Entity
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
this.fireworkAge = par1NBTTagCompound.getInteger("Life");
|
||||
this.lifetime = par1NBTTagCompound.getInteger("LifeTime");
|
||||
NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("FireworksItem");
|
||||
|
||||
if (nbttagcompound1 != null)
|
||||
{
|
||||
if (nbttagcompound1 != null) {
|
||||
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
this.dataWatcher.updateObject(8, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -225,8 +209,7 @@ public class EntityLandmineFirework extends Entity
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getShadowSize ()
|
||||
{
|
||||
public float getShadowSize() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@@ -234,15 +217,13 @@ public class EntityLandmineFirework extends Entity
|
||||
* Gets how bright this entity is.
|
||||
*/
|
||||
@Override
|
||||
public float getBrightness (float par1)
|
||||
{
|
||||
public float getBrightness(float par1) {
|
||||
return super.getBrightness(par1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBrightnessForRender (float par1)
|
||||
{
|
||||
public int getBrightnessForRender(float par1) {
|
||||
return super.getBrightnessForRender(par1);
|
||||
}
|
||||
|
||||
@@ -250,8 +231,7 @@ public class EntityLandmineFirework extends Entity
|
||||
* If returns false, the item will not inflict any damage against entities.
|
||||
*/
|
||||
@Override
|
||||
public boolean canAttackWithItem ()
|
||||
{
|
||||
public boolean canAttackWithItem() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -7,24 +7,23 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.*;
|
||||
import tconstruct.world.MiningExplosion;
|
||||
|
||||
public class ExplosivePrimed extends Entity
|
||||
{
|
||||
public class ExplosivePrimed extends Entity {
|
||||
/** How long the fuse is */
|
||||
public Block block;
|
||||
|
||||
public int metadata;
|
||||
public int fuse;
|
||||
private EntityLivingBase tntPlacedBy;
|
||||
|
||||
public ExplosivePrimed(World par1World)
|
||||
{
|
||||
public ExplosivePrimed(World par1World) {
|
||||
super(par1World);
|
||||
this.preventEntitySpawning = true;
|
||||
this.setSize(0.98F, 0.98F);
|
||||
this.yOffset = this.height / 2.0F;
|
||||
}
|
||||
|
||||
public ExplosivePrimed(World par1World, double par2, double par4, double par6, EntityLivingBase par8EntityLivingBase)
|
||||
{
|
||||
public ExplosivePrimed(
|
||||
World par1World, double par2, double par4, double par6, EntityLivingBase par8EntityLivingBase) {
|
||||
this(par1World);
|
||||
this.setPosition(par2, par4, par6);
|
||||
float f = (float) (Math.random() * Math.PI * 2.0D);
|
||||
@@ -39,17 +38,14 @@ public class ExplosivePrimed extends Entity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit ()
|
||||
{
|
||||
}
|
||||
protected void entityInit() {}
|
||||
|
||||
/**
|
||||
* returns if this entity triggers Block.onEntityWalking on the blocks they
|
||||
* walk on. used for spiders and wolves to prevent them from trampling crops
|
||||
*/
|
||||
@Override
|
||||
protected boolean canTriggerWalking ()
|
||||
{
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,8 +54,7 @@ public class ExplosivePrimed extends Entity
|
||||
* this Entity.
|
||||
*/
|
||||
@Override
|
||||
public boolean canBeCollidedWith ()
|
||||
{
|
||||
public boolean canBeCollidedWith() {
|
||||
return !this.isDead;
|
||||
}
|
||||
|
||||
@@ -67,8 +62,7 @@ public class ExplosivePrimed extends Entity
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate ()
|
||||
{
|
||||
public void onUpdate() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
@@ -78,36 +72,29 @@ public class ExplosivePrimed extends Entity
|
||||
this.motionY *= 0.9800000190734863D;
|
||||
this.motionZ *= 0.9800000190734863D;
|
||||
|
||||
if (this.onGround)
|
||||
{
|
||||
if (this.onGround) {
|
||||
this.motionX *= 0.699999988079071D;
|
||||
this.motionZ *= 0.699999988079071D;
|
||||
this.motionY *= -0.5D;
|
||||
}
|
||||
|
||||
if (this.fuse-- <= 0)
|
||||
{
|
||||
if (this.fuse-- <= 0) {
|
||||
this.setDead();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.explode();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
private void explode ()
|
||||
{
|
||||
private void explode() {
|
||||
float f = 5.0F;
|
||||
this.createExplosion(worldObj, this, this.posX, this.posY, this.posZ, f);
|
||||
}
|
||||
|
||||
public void createExplosion (World world, Entity par1Entity, double par2, double par4, double par6, float par8)
|
||||
{
|
||||
public void createExplosion(World world, Entity par1Entity, double par2, double par4, double par6, float par8) {
|
||||
Explosion explosion = new MiningExplosion(world, par1Entity, par2, par4, par6, par8);
|
||||
explosion.isFlaming = false;
|
||||
explosion.isSmoking = true;
|
||||
@@ -120,8 +107,7 @@ public class ExplosivePrimed extends Entity
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
@Override
|
||||
protected void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
par1NBTTagCompound.setByte("Fuse", (byte) this.fuse);
|
||||
}
|
||||
|
||||
@@ -129,23 +115,20 @@ public class ExplosivePrimed extends Entity
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
@Override
|
||||
protected void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
this.fuse = par1NBTTagCompound.getByte("Fuse");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getShadowSize ()
|
||||
{
|
||||
public float getShadowSize() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns null or the entityliving it was placed or ignited by
|
||||
*/
|
||||
public EntityLivingBase getTntPlacedBy ()
|
||||
{
|
||||
public EntityLivingBase getTntPlacedBy() {
|
||||
return this.tntPlacedBy;
|
||||
}
|
||||
}
|
||||
@@ -10,42 +10,34 @@ import tconstruct.mechworks.inventory.ContainerLandmine;
|
||||
import tconstruct.mechworks.landmine.behavior.Behavior;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class GuiLandmine extends GuiContainer
|
||||
{
|
||||
public class GuiLandmine extends GuiContainer {
|
||||
|
||||
ContainerLandmine container;
|
||||
|
||||
ResourceLocation background = new ResourceLocation("tinker:textures/gui/landmine.png");
|
||||
|
||||
public GuiLandmine(ContainerLandmine par1Container)
|
||||
{
|
||||
public GuiLandmine(ContainerLandmine par1Container) {
|
||||
super(par1Container);
|
||||
container = par1Container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderToolTip (ItemStack par1ItemStack, int par2, int par3)
|
||||
{
|
||||
protected void renderToolTip(ItemStack par1ItemStack, int par2, int par3) {
|
||||
List list = par1ItemStack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
Behavior b = Behavior.getBehaviorFromStack(par1ItemStack);
|
||||
if (b != null)
|
||||
{
|
||||
if (b != null) {
|
||||
b.getInformation(par1ItemStack, list);
|
||||
}
|
||||
|
||||
for (int k = 0; k < list.size(); ++k)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
for (int k = 0; k < list.size(); ++k) {
|
||||
if (k == 0) {
|
||||
list.set(k, par1ItemStack.getRarity().rarityColor + (String) list.get(k));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
|
||||
}
|
||||
}
|
||||
@@ -55,27 +47,21 @@ public class GuiLandmine extends GuiContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer (int i, int j)
|
||||
{
|
||||
if (container.te != null)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
if (container.te != null) {
|
||||
fontRendererObj.drawString(container.te.getInventoryName(), 8, 5, 4210752);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("gui.landmine"), 8, 5, 4210752);
|
||||
}
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
|
||||
{
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(background);
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,12 +10,11 @@ import tconstruct.mechworks.TinkerMechworks;
|
||||
import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ContainerLandmine extends Container
|
||||
{
|
||||
public class ContainerLandmine extends Container {
|
||||
|
||||
public TileEntityLandmine te;
|
||||
public EntityPlayer entityPlayer;
|
||||
@@ -23,62 +22,53 @@ public class ContainerLandmine extends Container
|
||||
private int field_94535_f = -1;
|
||||
private final Set field_94537_h = new HashSet();
|
||||
|
||||
public ContainerLandmine(EntityPlayer player, TileEntityLandmine te)
|
||||
{
|
||||
public ContainerLandmine(EntityPlayer player, TileEntityLandmine te) {
|
||||
this.te = te;
|
||||
this.entityPlayer = player;
|
||||
addInventorySlots(te);
|
||||
bindPlayerInventory(player.inventory);
|
||||
}
|
||||
|
||||
public void addInventorySlots (TileEntityLandmine inv)
|
||||
{
|
||||
public void addInventorySlots(TileEntityLandmine inv) {
|
||||
addSlotToContainer(new SlotBehavedOnly(inv, 0, 35, 53));
|
||||
addSlotToContainer(new SlotBehavedOnly(inv, 1, 80, 53));
|
||||
addSlotToContainer(new SlotBehavedOnly(inv, 2, 125, 53));
|
||||
addSlotToContainer(new SlotOpaqueBlocksOnly(inv, 3, 80, 21));
|
||||
}
|
||||
|
||||
public void bindPlayerInventory (InventoryPlayer inventory)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
public void bindPlayerInventory(InventoryPlayer inventory) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
for (int i = 0; i < 9; i++) {
|
||||
addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
Block block = te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord);
|
||||
if (block != TinkerMechworks.landmine)
|
||||
return false;
|
||||
if (block != TinkerMechworks.landmine) return false;
|
||||
return te.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer par1EntityPlayer, int par2)
|
||||
{
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
|
||||
// This code actually works perfectly, but does not respect the global
|
||||
// TileEntity stack limit, shift clicking ability disabled.
|
||||
/*
|
||||
* ItemStack itemstack = null; Slot slot = (Slot)
|
||||
* this.inventorySlots.get(par2);
|
||||
*
|
||||
*
|
||||
* if (slot != null && slot.getHasStack()) { ItemStack itemstack1 =
|
||||
* slot.getStack(); itemstack = itemstack1.copy();
|
||||
*
|
||||
*
|
||||
* if (par2 == 2) { if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
|
||||
* return null; }
|
||||
*
|
||||
*
|
||||
* slot.onSlotChange(itemstack1, itemstack); } else if (par2 != 1 &&
|
||||
* par2 != 0) { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { if
|
||||
* (!this.mergeItemStack(itemstack1, 1, 2, false)) { if
|
||||
@@ -86,14 +76,14 @@ public class ContainerLandmine extends Container
|
||||
* else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1,
|
||||
* 3, 30, false)) { return null; } } } } else if
|
||||
* (!this.mergeItemStack(itemstack1, 3, 39, false)) { return null; }
|
||||
*
|
||||
*
|
||||
* if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); }
|
||||
* else { slot.onSlotChanged(); }
|
||||
*
|
||||
*
|
||||
* if (itemstack1.stackSize == itemstack.stackSize) { return null; }
|
||||
*
|
||||
*
|
||||
* slot.onPickupFromSlot(par1EntityPlayer, itemstack1); }
|
||||
*
|
||||
*
|
||||
* return itemstack;
|
||||
*/
|
||||
return null;
|
||||
@@ -101,74 +91,62 @@ public class ContainerLandmine extends Container
|
||||
|
||||
/* Disabled for another(less buggy and sticky) system */
|
||||
@Override
|
||||
public ItemStack slotClick (int par1, int par2, int par3, EntityPlayer par4EntityPlayer)
|
||||
{
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
|
||||
ItemStack itemstack = null;
|
||||
InventoryPlayer inventoryplayer = par4EntityPlayer.inventory;
|
||||
int l;
|
||||
ItemStack itemstack1;
|
||||
|
||||
if (par3 == 5)
|
||||
{
|
||||
if (par3 == 5) {
|
||||
int i1 = this.field_94536_g;
|
||||
this.field_94536_g = func_94532_c(par2);
|
||||
|
||||
if ((i1 != 1 || this.field_94536_g != 2) && i1 != this.field_94536_g)
|
||||
{
|
||||
if ((i1 != 1 || this.field_94536_g != 2) && i1 != this.field_94536_g) {
|
||||
this.func_94533_d();
|
||||
}
|
||||
else if (inventoryplayer.getItemStack() == null)
|
||||
{
|
||||
} else if (inventoryplayer.getItemStack() == null) {
|
||||
this.func_94533_d();
|
||||
}
|
||||
else if (this.field_94536_g == 0)
|
||||
{
|
||||
} else if (this.field_94536_g == 0) {
|
||||
this.field_94535_f = func_94529_b(par2);
|
||||
|
||||
if (func_94528_d(this.field_94535_f))
|
||||
{
|
||||
if (func_94528_d(this.field_94535_f)) {
|
||||
this.field_94536_g = 1;
|
||||
this.field_94537_h.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.func_94533_d();
|
||||
}
|
||||
}
|
||||
else if (this.field_94536_g == 1)
|
||||
{
|
||||
} else if (this.field_94536_g == 1) {
|
||||
Slot slot = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (slot != null && func_94527_a(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize > this.field_94537_h.size() && this.canDragIntoSlot(slot))
|
||||
{
|
||||
if (slot != null
|
||||
&& func_94527_a(slot, inventoryplayer.getItemStack(), true)
|
||||
&& slot.isItemValid(inventoryplayer.getItemStack())
|
||||
&& inventoryplayer.getItemStack().stackSize > this.field_94537_h.size()
|
||||
&& this.canDragIntoSlot(slot)) {
|
||||
this.field_94537_h.add(slot);
|
||||
}
|
||||
}
|
||||
else if (this.field_94536_g == 2)
|
||||
{
|
||||
if (!this.field_94537_h.isEmpty())
|
||||
{
|
||||
} else if (this.field_94536_g == 2) {
|
||||
if (!this.field_94537_h.isEmpty()) {
|
||||
itemstack1 = inventoryplayer.getItemStack().copy();
|
||||
l = inventoryplayer.getItemStack().stackSize;
|
||||
Iterator iterator = this.field_94537_h.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
|
||||
if (slot1 != null && func_94527_a(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize >= this.field_94537_h.size() && this.canDragIntoSlot(slot1))
|
||||
{
|
||||
if (slot1 != null
|
||||
&& func_94527_a(slot1, inventoryplayer.getItemStack(), true)
|
||||
&& slot1.isItemValid(inventoryplayer.getItemStack())
|
||||
&& inventoryplayer.getItemStack().stackSize >= this.field_94537_h.size()
|
||||
&& this.canDragIntoSlot(slot1)) {
|
||||
ItemStack itemstack2 = itemstack1.copy();
|
||||
int j1 = slot1.getHasStack() ? slot1.getStack().stackSize : 0;
|
||||
func_94525_a(this.field_94537_h, this.field_94535_f, itemstack2, j1);
|
||||
|
||||
if (itemstack2.stackSize > itemstack2.getMaxStackSize())
|
||||
{
|
||||
if (itemstack2.stackSize > itemstack2.getMaxStackSize()) {
|
||||
itemstack2.stackSize = itemstack2.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack2.stackSize > slot1.getSlotStackLimit())
|
||||
{
|
||||
if (itemstack2.stackSize > slot1.getSlotStackLimit()) {
|
||||
itemstack2.stackSize = slot1.getSlotStackLimit();
|
||||
}
|
||||
|
||||
@@ -179,8 +157,7 @@ public class ContainerLandmine extends Container
|
||||
|
||||
itemstack1.stackSize = l;
|
||||
|
||||
if (itemstack1.stackSize <= 0)
|
||||
{
|
||||
if (itemstack1.stackSize <= 0) {
|
||||
itemstack1 = null;
|
||||
}
|
||||
|
||||
@@ -188,49 +165,35 @@ public class ContainerLandmine extends Container
|
||||
}
|
||||
|
||||
this.func_94533_d();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.func_94533_d();
|
||||
}
|
||||
}
|
||||
else if (this.field_94536_g != 0)
|
||||
{
|
||||
} else if (this.field_94536_g != 0) {
|
||||
this.func_94533_d();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Slot slot2;
|
||||
int k1;
|
||||
ItemStack itemstack3;
|
||||
|
||||
if ((par3 == 0 || par3 == 1) && (par2 == 0 || par2 == 1))
|
||||
{
|
||||
if (par1 == -999)
|
||||
{
|
||||
if (inventoryplayer.getItemStack() != null && par1 == -999)
|
||||
{
|
||||
if (par2 == 0)
|
||||
{
|
||||
if ((par3 == 0 || par3 == 1) && (par2 == 0 || par2 == 1)) {
|
||||
if (par1 == -999) {
|
||||
if (inventoryplayer.getItemStack() != null && par1 == -999) {
|
||||
if (par2 == 0) {
|
||||
par4EntityPlayer.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), false);
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
|
||||
if (par2 == 1)
|
||||
{
|
||||
par4EntityPlayer.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().splitStack(1), false);
|
||||
if (par2 == 1) {
|
||||
par4EntityPlayer.dropPlayerItemWithRandomChoice(
|
||||
inventoryplayer.getItemStack().splitStack(1), false);
|
||||
|
||||
if (inventoryplayer.getItemStack().stackSize == 0)
|
||||
{
|
||||
if (inventoryplayer.getItemStack().stackSize == 0) {
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (par3 == 1)
|
||||
{
|
||||
if (par1 < 0)
|
||||
{
|
||||
} else if (par3 == 1) {
|
||||
if (par1 < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -238,26 +201,22 @@ public class ContainerLandmine extends Container
|
||||
|
||||
slot2 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (slot2 != null && slot2.canTakeStack(par4EntityPlayer))
|
||||
{
|
||||
if (slot2 != null && slot2.canTakeStack(par4EntityPlayer)) {
|
||||
itemstack1 = this.transferStackInSlot(par4EntityPlayer, par1);
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
if (itemstack1 != null) {
|
||||
localObject2 = ((ItemStack) itemstack1).getItem();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slot2 != null && slot2.getStack() != null && slot2.getStack().getItem() == localObject2)
|
||||
{
|
||||
if (slot2 != null
|
||||
&& slot2.getStack() != null
|
||||
&& slot2.getStack().getItem() == localObject2) {
|
||||
this.retrySlotClick(par1, par2, true, par4EntityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1 < 0)
|
||||
{
|
||||
} else {
|
||||
if (par1 < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -265,119 +224,94 @@ public class ContainerLandmine extends Container
|
||||
|
||||
boolean shouldDoStuff = true;
|
||||
|
||||
if ((!(slot2 instanceof SlotBehavedOnly)))
|
||||
{
|
||||
if ((!(slot2 instanceof SlotBehavedOnly))) {
|
||||
shouldDoStuff = false;
|
||||
}
|
||||
|
||||
if (slot2 != null)
|
||||
{
|
||||
if (slot2 != null) {
|
||||
itemstack1 = slot2.getStack();
|
||||
ItemStack itemstack4 = inventoryplayer.getItemStack();
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
if (itemstack1 != null) {
|
||||
itemstack = itemstack1.copy();
|
||||
}
|
||||
|
||||
if (itemstack1 == null)
|
||||
{
|
||||
if (itemstack4 != null && slot2.isItemValid(itemstack4))
|
||||
{
|
||||
if (itemstack1 == null) {
|
||||
if (itemstack4 != null && slot2.isItemValid(itemstack4)) {
|
||||
k1 = par2 == 0 ? itemstack4.stackSize : 1;
|
||||
|
||||
if (k1 > slot2.getSlotStackLimit())
|
||||
{
|
||||
if (k1 > slot2.getSlotStackLimit()) {
|
||||
k1 = slot2.getSlotStackLimit();
|
||||
}
|
||||
|
||||
if (itemstack4.stackSize >= k1)
|
||||
{
|
||||
if (itemstack4.stackSize >= k1) {
|
||||
slot2.putStack(itemstack4.splitStack(k1));
|
||||
}
|
||||
|
||||
if (itemstack4.stackSize == 0)
|
||||
{
|
||||
if (itemstack4.stackSize == 0) {
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
}
|
||||
else if (shouldDoStuff && slot2 instanceof SlotBehavedOnly && itemstack4 != null && slot2.isItemValid(new ItemStack(itemstack4.getItem(), 1, itemstack4.getItemDamage())))
|
||||
{
|
||||
} else if (shouldDoStuff
|
||||
&& slot2 instanceof SlotBehavedOnly
|
||||
&& itemstack4 != null
|
||||
&& slot2.isItemValid(
|
||||
new ItemStack(itemstack4.getItem(), 1, itemstack4.getItemDamage()))) {
|
||||
k1 = par2 == 0 ? 1 : 1;
|
||||
|
||||
if (k1 > slot2.getSlotStackLimit())
|
||||
{
|
||||
if (k1 > slot2.getSlotStackLimit()) {
|
||||
k1 = slot2.getSlotStackLimit();
|
||||
}
|
||||
|
||||
if (itemstack4.stackSize >= k1)
|
||||
{
|
||||
if (itemstack4.stackSize >= k1) {
|
||||
slot2.putStack(itemstack4.splitStack(k1));
|
||||
}
|
||||
|
||||
if (itemstack4.stackSize == 0)
|
||||
{
|
||||
if (itemstack4.stackSize == 0) {
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (slot2.canTakeStack(par4EntityPlayer))
|
||||
{
|
||||
if (itemstack4 == null)
|
||||
{
|
||||
} else if (slot2.canTakeStack(par4EntityPlayer)) {
|
||||
if (itemstack4 == null) {
|
||||
k1 = par2 == 0 ? itemstack1.stackSize : (itemstack1.stackSize + 1) / 2;
|
||||
itemstack3 = slot2.decrStackSize(k1);
|
||||
inventoryplayer.setItemStack(itemstack3);
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot2.putStack((ItemStack) null);
|
||||
}
|
||||
|
||||
slot2.onPickupFromSlot(par4EntityPlayer, inventoryplayer.getItemStack());
|
||||
}
|
||||
else if (slot2.isItemValid(itemstack4))
|
||||
{
|
||||
if (ItemStack.areItemStacksEqual(itemstack1, itemstack4))
|
||||
{
|
||||
} else if (slot2.isItemValid(itemstack4)) {
|
||||
if (ItemStack.areItemStacksEqual(itemstack1, itemstack4)) {
|
||||
k1 = par2 == 0 ? itemstack4.stackSize : 1;
|
||||
|
||||
if (k1 > slot2.getSlotStackLimit() - itemstack1.stackSize)
|
||||
{
|
||||
if (k1 > slot2.getSlotStackLimit() - itemstack1.stackSize) {
|
||||
k1 = slot2.getSlotStackLimit() - itemstack1.stackSize;
|
||||
}
|
||||
|
||||
if (k1 > itemstack4.getMaxStackSize() - itemstack1.stackSize)
|
||||
{
|
||||
if (k1 > itemstack4.getMaxStackSize() - itemstack1.stackSize) {
|
||||
k1 = itemstack4.getMaxStackSize() - itemstack1.stackSize;
|
||||
}
|
||||
|
||||
itemstack4.splitStack(k1);
|
||||
|
||||
if (itemstack4.stackSize == 0)
|
||||
{
|
||||
if (itemstack4.stackSize == 0) {
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
|
||||
itemstack1.stackSize += k1;
|
||||
}
|
||||
else if (itemstack4.stackSize <= slot2.getSlotStackLimit())
|
||||
{
|
||||
} else if (itemstack4.stackSize <= slot2.getSlotStackLimit()) {
|
||||
slot2.putStack(itemstack4);
|
||||
inventoryplayer.setItemStack(itemstack1);
|
||||
}
|
||||
}
|
||||
else if (ItemStack.areItemStacksEqual(itemstack1, itemstack4))
|
||||
{
|
||||
} else if (ItemStack.areItemStacksEqual(itemstack1, itemstack4)) {
|
||||
k1 = itemstack1.stackSize;
|
||||
|
||||
if (k1 > 0 && k1 + itemstack4.stackSize <= itemstack4.getMaxStackSize())
|
||||
{
|
||||
if (k1 > 0 && k1 + itemstack4.stackSize <= itemstack4.getMaxStackSize()) {
|
||||
itemstack4.stackSize += k1;
|
||||
itemstack1 = slot2.decrStackSize(k1);
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot2.putStack((ItemStack) null);
|
||||
}
|
||||
|
||||
@@ -389,98 +323,92 @@ public class ContainerLandmine extends Container
|
||||
slot2.onSlotChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (par3 == 2 && par2 >= 0 && par2 < 9)
|
||||
{
|
||||
} else if (par3 == 2 && par2 >= 0 && par2 < 9) {
|
||||
slot2 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (slot2.canTakeStack(par4EntityPlayer))
|
||||
{
|
||||
if (slot2.canTakeStack(par4EntityPlayer)) {
|
||||
itemstack1 = inventoryplayer.getStackInSlot(par2);
|
||||
boolean flag = itemstack1 == null || slot2.inventory == inventoryplayer && slot2.isItemValid(itemstack1);
|
||||
boolean flag =
|
||||
itemstack1 == null || slot2.inventory == inventoryplayer && slot2.isItemValid(itemstack1);
|
||||
k1 = -1;
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
if (!flag) {
|
||||
k1 = inventoryplayer.getFirstEmptyStack();
|
||||
flag |= k1 > -1;
|
||||
}
|
||||
|
||||
if (slot2.getHasStack() && flag)
|
||||
{
|
||||
if (slot2.getHasStack() && flag) {
|
||||
itemstack3 = slot2.getStack();
|
||||
inventoryplayer.setInventorySlotContents(par2, itemstack3.copy());
|
||||
|
||||
if ((slot2.inventory != inventoryplayer || !slot2.isItemValid(itemstack1)) && itemstack1 != null)
|
||||
{
|
||||
if (k1 > -1)
|
||||
{
|
||||
if ((slot2.inventory != inventoryplayer || !slot2.isItemValid(itemstack1))
|
||||
&& itemstack1 != null) {
|
||||
if (k1 > -1) {
|
||||
inventoryplayer.addItemStackToInventory(itemstack1);
|
||||
slot2.decrStackSize(itemstack3.stackSize);
|
||||
slot2.putStack((ItemStack) null);
|
||||
slot2.onPickupFromSlot(par4EntityPlayer, itemstack3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
slot2.decrStackSize(itemstack3.stackSize);
|
||||
slot2.putStack(itemstack1);
|
||||
slot2.onPickupFromSlot(par4EntityPlayer, itemstack3);
|
||||
}
|
||||
}
|
||||
else if (!slot2.getHasStack() && itemstack1 != null && slot2.isItemValid(itemstack1))
|
||||
{
|
||||
} else if (!slot2.getHasStack() && itemstack1 != null && slot2.isItemValid(itemstack1)) {
|
||||
inventoryplayer.setInventorySlotContents(par2, (ItemStack) null);
|
||||
slot2.putStack(itemstack1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (par3 == 3 && par4EntityPlayer.capabilities.isCreativeMode && inventoryplayer.getItemStack() == null && par1 >= 0)
|
||||
{
|
||||
} else if (par3 == 3
|
||||
&& par4EntityPlayer.capabilities.isCreativeMode
|
||||
&& inventoryplayer.getItemStack() == null
|
||||
&& par1 >= 0) {
|
||||
slot2 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (slot2 != null && slot2.getHasStack())
|
||||
{
|
||||
if (slot2 != null && slot2.getHasStack()) {
|
||||
itemstack1 = slot2.getStack().copy();
|
||||
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||
inventoryplayer.setItemStack(itemstack1);
|
||||
}
|
||||
}
|
||||
else if (par3 == 4 && inventoryplayer.getItemStack() == null && par1 >= 0)
|
||||
{
|
||||
} else if (par3 == 4 && inventoryplayer.getItemStack() == null && par1 >= 0) {
|
||||
slot2 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (slot2 != null && slot2.getHasStack() && slot2.canTakeStack(par4EntityPlayer))
|
||||
{
|
||||
if (slot2 != null && slot2.getHasStack() && slot2.canTakeStack(par4EntityPlayer)) {
|
||||
itemstack1 = slot2.decrStackSize(par2 == 0 ? 1 : slot2.getStack().stackSize);
|
||||
slot2.onPickupFromSlot(par4EntityPlayer, itemstack1);
|
||||
par4EntityPlayer.dropPlayerItemWithRandomChoice(itemstack1, false);
|
||||
}
|
||||
}
|
||||
else if (par3 == 6 && par1 >= 0)
|
||||
{
|
||||
} else if (par3 == 6 && par1 >= 0) {
|
||||
slot2 = (Slot) this.inventorySlots.get(par1);
|
||||
itemstack1 = inventoryplayer.getItemStack();
|
||||
|
||||
if (itemstack1 != null && (slot2 == null || !slot2.getHasStack() || !slot2.canTakeStack(par4EntityPlayer)))
|
||||
{
|
||||
if (itemstack1 != null
|
||||
&& (slot2 == null || !slot2.getHasStack() || !slot2.canTakeStack(par4EntityPlayer))) {
|
||||
l = par2 == 0 ? 0 : this.inventorySlots.size() - 1;
|
||||
k1 = par2 == 0 ? 1 : -1;
|
||||
|
||||
for (int l1 = 0; l1 < 2; ++l1)
|
||||
{
|
||||
for (int i2 = l; i2 >= 0 && i2 < this.inventorySlots.size() && itemstack1.stackSize < itemstack1.getMaxStackSize(); i2 += k1)
|
||||
{
|
||||
for (int l1 = 0; l1 < 2; ++l1) {
|
||||
for (int i2 = l;
|
||||
i2 >= 0
|
||||
&& i2 < this.inventorySlots.size()
|
||||
&& itemstack1.stackSize < itemstack1.getMaxStackSize();
|
||||
i2 += k1) {
|
||||
Slot slot3 = (Slot) this.inventorySlots.get(i2);
|
||||
|
||||
if (slot3.getHasStack() && func_94527_a(slot3, itemstack1, true) && slot3.canTakeStack(par4EntityPlayer) && this.func_94530_a(itemstack1, slot3) && (l1 != 0 || slot3.getStack().stackSize != slot3.getStack().getMaxStackSize()))
|
||||
{
|
||||
int j2 = Math.min(itemstack1.getMaxStackSize() - itemstack1.stackSize, slot3.getStack().stackSize);
|
||||
if (slot3.getHasStack()
|
||||
&& func_94527_a(slot3, itemstack1, true)
|
||||
&& slot3.canTakeStack(par4EntityPlayer)
|
||||
&& this.func_94530_a(itemstack1, slot3)
|
||||
&& (l1 != 0
|
||||
|| slot3.getStack().stackSize
|
||||
!= slot3.getStack().getMaxStackSize())) {
|
||||
int j2 = Math.min(
|
||||
itemstack1.getMaxStackSize() - itemstack1.stackSize,
|
||||
slot3.getStack().stackSize);
|
||||
ItemStack itemstack5 = slot3.decrStackSize(j2);
|
||||
itemstack1.stackSize += j2;
|
||||
|
||||
if (itemstack5.stackSize <= 0)
|
||||
{
|
||||
if (itemstack5.stackSize <= 0) {
|
||||
slot3.putStack((ItemStack) null);
|
||||
}
|
||||
|
||||
@@ -498,9 +426,7 @@ public class ContainerLandmine extends Container
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDragIntoSlot (Slot par1Slot)
|
||||
{
|
||||
public boolean canDragIntoSlot(Slot par1Slot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,64 +10,66 @@ import tconstruct.mechworks.TinkerMechworks;
|
||||
import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ItemBlockLandmine extends ItemBlock
|
||||
{
|
||||
public class ItemBlockLandmine extends ItemBlock {
|
||||
|
||||
public ItemBlockLandmine(Block b)
|
||||
{
|
||||
public ItemBlockLandmine(Block b) {
|
||||
super(b);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation (ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
String interaction = null;
|
||||
|
||||
switch (par1ItemStack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
interaction = StatCollector.translateToLocal("landmine1.tooltip");
|
||||
break;
|
||||
case 1:
|
||||
interaction = StatCollector.translateToLocal("landmine2.tooltip");
|
||||
break;
|
||||
case 2:
|
||||
interaction = StatCollector.translateToLocal("landmine3.tooltip");
|
||||
break;
|
||||
default:
|
||||
interaction = StatCollector.translateToLocal("landmine4.tooltip");
|
||||
break;
|
||||
switch (par1ItemStack.getItemDamage()) {
|
||||
case 0:
|
||||
interaction = StatCollector.translateToLocal("landmine1.tooltip");
|
||||
break;
|
||||
case 1:
|
||||
interaction = StatCollector.translateToLocal("landmine2.tooltip");
|
||||
break;
|
||||
case 2:
|
||||
interaction = StatCollector.translateToLocal("landmine3.tooltip");
|
||||
break;
|
||||
default:
|
||||
interaction = StatCollector.translateToLocal("landmine4.tooltip");
|
||||
break;
|
||||
}
|
||||
|
||||
par3List.add(StatCollector.translateToLocal("landmine5.tooltip") + interaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata (int par1)
|
||||
{
|
||||
public int getMetadata(int par1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
if (!world.setBlock(x, y, z, TinkerMechworks.landmine, metadata, 3))
|
||||
{
|
||||
public boolean placeBlockAt(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float hitX,
|
||||
float hitY,
|
||||
float hitZ,
|
||||
int metadata) {
|
||||
if (!world.setBlock(x, y, z, TinkerMechworks.landmine, metadata, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == TinkerMechworks.landmine)
|
||||
{
|
||||
if (world.getBlock(x, y, z) == TinkerMechworks.landmine) {
|
||||
TinkerMechworks.landmine.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine) world.getTileEntity(x, y, z);
|
||||
if (te == null)
|
||||
{
|
||||
if (te == null) {
|
||||
te = (TileEntityLandmine) TinkerMechworks.landmine.createTileEntity(world, metadata);
|
||||
}
|
||||
|
||||
@@ -80,9 +82,7 @@ public class ItemBlockLandmine extends ItemBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Random getRandom ()
|
||||
{
|
||||
public static Random getRandom() {
|
||||
return itemRand;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,40 +5,36 @@ import net.minecraft.client.renderer.*;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Helper
|
||||
{
|
||||
public class Helper {
|
||||
|
||||
public static ForgeDirection convertMetaToForgeOrientation (int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 6:
|
||||
return ForgeDirection.DOWN;
|
||||
case 7:
|
||||
return ForgeDirection.UP;
|
||||
case 1:
|
||||
return ForgeDirection.WEST;
|
||||
case 3:
|
||||
return ForgeDirection.NORTH;
|
||||
case 2:
|
||||
return ForgeDirection.EAST;
|
||||
case 4:
|
||||
return ForgeDirection.SOUTH;
|
||||
case 5:
|
||||
return ForgeDirection.DOWN;
|
||||
case 0:
|
||||
return ForgeDirection.UP;
|
||||
public static ForgeDirection convertMetaToForgeOrientation(int metadata) {
|
||||
switch (metadata) {
|
||||
case 6:
|
||||
return ForgeDirection.DOWN;
|
||||
case 7:
|
||||
return ForgeDirection.UP;
|
||||
case 1:
|
||||
return ForgeDirection.WEST;
|
||||
case 3:
|
||||
return ForgeDirection.NORTH;
|
||||
case 2:
|
||||
return ForgeDirection.EAST;
|
||||
case 4:
|
||||
return ForgeDirection.SOUTH;
|
||||
case 5:
|
||||
return ForgeDirection.DOWN;
|
||||
case 0:
|
||||
return ForgeDirection.UP;
|
||||
}
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public static void renderInventoryCube (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
public static void renderInventoryCube(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
@@ -71,5 +67,4 @@ public class Helper
|
||||
renderer.renderFaceZNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,34 +3,29 @@ package tconstruct.mechworks.landmine;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
public class LandmineStack
|
||||
{
|
||||
public class LandmineStack {
|
||||
|
||||
public final boolean isBlock;
|
||||
public final Block block;
|
||||
public final Item item;
|
||||
public final int meta;
|
||||
|
||||
public LandmineStack(Block block)
|
||||
{
|
||||
public LandmineStack(Block block) {
|
||||
this(block, -314159265);
|
||||
}
|
||||
|
||||
public LandmineStack(Item item)
|
||||
{
|
||||
public LandmineStack(Item item) {
|
||||
this(item, -314159265);
|
||||
}
|
||||
|
||||
public LandmineStack(Block block, int meta)
|
||||
{
|
||||
public LandmineStack(Block block, int meta) {
|
||||
isBlock = true;
|
||||
this.block = block;
|
||||
this.item = null;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public LandmineStack(Item item, int meta)
|
||||
{
|
||||
public LandmineStack(Item item, int meta) {
|
||||
isBlock = false;
|
||||
this.block = null;
|
||||
this.item = item;
|
||||
@@ -38,42 +33,28 @@ public class LandmineStack
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object o)
|
||||
{
|
||||
public boolean equals(Object o) {
|
||||
// Comparing landmine stacks
|
||||
if (o instanceof LandmineStack)
|
||||
{
|
||||
if (o instanceof LandmineStack) {
|
||||
LandmineStack stack = (LandmineStack) o;
|
||||
if (isBlock)
|
||||
{
|
||||
if (isBlock) {
|
||||
return block == stack.block && (meta == stack.meta || meta == -314159265);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return item == stack.item && (meta == stack.meta || meta == -314159265);
|
||||
}
|
||||
// Comparing landmine stacks with item stacks
|
||||
}
|
||||
else if (o instanceof ItemStack)
|
||||
{
|
||||
} else if (o instanceof ItemStack) {
|
||||
ItemStack stack = (ItemStack) o;
|
||||
if (isBlock && stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
return block == ((ItemBlock) stack.getItem()).field_150939_a && (meta == stack.getItemDamage() || meta == -314159265);
|
||||
}
|
||||
else if (!isBlock)
|
||||
{
|
||||
if (isBlock && stack.getItem() instanceof ItemBlock) {
|
||||
return block == ((ItemBlock) stack.getItem()).field_150939_a
|
||||
&& (meta == stack.getItemDamage() || meta == -314159265);
|
||||
} else if (!isBlock) {
|
||||
return item == stack.getItem() && (meta == stack.getItemDamage() || meta == -314159265);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,12 +11,11 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.mechworks.landmine.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class Behavior
|
||||
{
|
||||
public abstract class Behavior {
|
||||
|
||||
public static HashMap<LandmineStack, Behavior> behaviorsListItems = new HashMap<LandmineStack, Behavior>();
|
||||
public static HashMap<LandmineStack, Behavior> behaviorsListBlocks = new HashMap<LandmineStack, Behavior>();
|
||||
@@ -33,8 +32,7 @@ public abstract class Behavior
|
||||
public static Behavior shoot = new BehaviorProjectile();
|
||||
public static Behavior shear = new BehaviorShears();
|
||||
|
||||
public static void registerBuiltInBehaviors ()
|
||||
{
|
||||
public static void registerBuiltInBehaviors() {
|
||||
defaultBehavior = new BehaviorDefault();
|
||||
|
||||
addBehavior(new LandmineStack(Items.stick), dummy);
|
||||
@@ -54,161 +52,136 @@ public abstract class Behavior
|
||||
// Make sure the part below this comment is executed last(to avoid
|
||||
// conflicts)
|
||||
Iterator i1 = Block.blockRegistry.iterator();
|
||||
while (i1.hasNext())
|
||||
{
|
||||
while (i1.hasNext()) {
|
||||
Object ob = i1.next();
|
||||
if (ob != null && ob instanceof Block)
|
||||
{
|
||||
if (ob != null && ob instanceof Block) {
|
||||
Block b = (Block) ob;
|
||||
if (b.getMaterial().isOpaque() && b.renderAsNormalBlock() && !b.canProvidePower() && !(b instanceof ITileEntityProvider) && !behaviorsListBlocks.containsKey(new ItemStack(b)))
|
||||
{
|
||||
if (b.getMaterial().isOpaque()
|
||||
&& b.renderAsNormalBlock()
|
||||
&& !b.canProvidePower()
|
||||
&& !(b instanceof ITileEntityProvider)
|
||||
&& !behaviorsListBlocks.containsKey(new ItemStack(b))) {
|
||||
addBehavior(new LandmineStack(b), blockThrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Behavior getBehaviorFromStack (ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack == null)
|
||||
{
|
||||
public static Behavior getBehaviorFromStack(ItemStack par1ItemStack) {
|
||||
if (par1ItemStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (par1ItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (!behaviorsListBlocks.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < behaviorsListBlocks.size(); i++)
|
||||
{
|
||||
LandmineStack st = (LandmineStack) behaviorsListBlocks.keySet().toArray()[i];
|
||||
if (st.equals(par1ItemStack))
|
||||
{
|
||||
if (par1ItemStack.getItem() instanceof ItemBlock) {
|
||||
if (!behaviorsListBlocks.isEmpty()) {
|
||||
for (int i = 0; i < behaviorsListBlocks.size(); i++) {
|
||||
LandmineStack st =
|
||||
(LandmineStack) behaviorsListBlocks.keySet().toArray()[i];
|
||||
if (st.equals(par1ItemStack)) {
|
||||
return (Behavior) behaviorsListBlocks.values().toArray()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!behaviorsListItems.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < behaviorsListItems.size(); i++)
|
||||
{
|
||||
LandmineStack st = (LandmineStack) behaviorsListItems.keySet().toArray()[i];
|
||||
if (st.equals(par1ItemStack))
|
||||
{
|
||||
} else {
|
||||
if (!behaviorsListItems.isEmpty()) {
|
||||
for (int i = 0; i < behaviorsListItems.size(); i++) {
|
||||
LandmineStack st =
|
||||
(LandmineStack) behaviorsListItems.keySet().toArray()[i];
|
||||
if (st.equals(par1ItemStack)) {
|
||||
return (Behavior) behaviorsListItems.values().toArray()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Behavior getDefaulBehavior ()
|
||||
{
|
||||
public static Behavior getDefaulBehavior() {
|
||||
return defaultBehavior;
|
||||
}
|
||||
|
||||
public static void addBehavior (LandmineStack par1LandmineStack, Behavior par2Behavior)
|
||||
{
|
||||
if (par1LandmineStack.isBlock)
|
||||
{
|
||||
if (!behaviorsListBlocks.containsKey(par1LandmineStack))
|
||||
{
|
||||
public static void addBehavior(LandmineStack par1LandmineStack, Behavior par2Behavior) {
|
||||
if (par1LandmineStack.isBlock) {
|
||||
if (!behaviorsListBlocks.containsKey(par1LandmineStack)) {
|
||||
behaviorsListBlocks.put(par1LandmineStack, par2Behavior);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!behaviorsListItems.containsKey(par1LandmineStack))
|
||||
{
|
||||
} else {
|
||||
if (!behaviorsListItems.containsKey(par1LandmineStack)) {
|
||||
behaviorsListItems.put(par1LandmineStack, par2Behavior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved);
|
||||
public abstract void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved);
|
||||
|
||||
public int getStackLimit (ItemStack par1ItemStack)
|
||||
{
|
||||
public int getStackLimit(ItemStack par1ItemStack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void getInformation (ItemStack par1ItemStack, List par2List)
|
||||
{
|
||||
}
|
||||
public void getInformation(ItemStack par1ItemStack, List par2List) {}
|
||||
|
||||
// Will return false if the effect does not stack among the slots
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
public boolean effectStacks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public EnumFacing getFacing (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
public EnumFacing getFacing(World par1World, int par2, int par3, int par4) {
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(par1World.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return EnumFacing.UP;
|
||||
case UP:
|
||||
return EnumFacing.DOWN;
|
||||
case WEST:
|
||||
return EnumFacing.WEST;
|
||||
case EAST:
|
||||
return EnumFacing.EAST;
|
||||
case SOUTH:
|
||||
return EnumFacing.NORTH;
|
||||
case NORTH:
|
||||
return EnumFacing.SOUTH;
|
||||
default:
|
||||
return EnumFacing.UP;
|
||||
switch (dir) {
|
||||
case DOWN:
|
||||
return EnumFacing.UP;
|
||||
case UP:
|
||||
return EnumFacing.DOWN;
|
||||
case WEST:
|
||||
return EnumFacing.WEST;
|
||||
case EAST:
|
||||
return EnumFacing.EAST;
|
||||
case SOUTH:
|
||||
return EnumFacing.NORTH;
|
||||
case NORTH:
|
||||
return EnumFacing.SOUTH;
|
||||
default:
|
||||
return EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean doesBehaviorPreventRemovalOfBlock (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean doesBehaviorPreventRemovalOfBlock(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isBehaviorExchangableWithOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isBehaviorExchangableWithOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockGetRemoved)
|
||||
{
|
||||
public boolean shouldItemBeRemoved(ItemStack par1ItemStack, boolean willBlockGetRemoved) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final int arrayIndexOfStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
public static final int arrayIndexOfStack(ArrayList<ItemStack> stacks, ItemStack item) {
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
|
||||
int index = 0;
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
while (i1.hasNext()) {
|
||||
ItemStack stack = i1.next();
|
||||
if (stack.isItemEqual(item))
|
||||
{
|
||||
if (stack.isItemEqual(item)) {
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
@@ -217,15 +190,12 @@ public abstract class Behavior
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static final boolean arrayContainsEqualStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
public static final boolean arrayContainsEqualStack(ArrayList<ItemStack> stacks, ItemStack item) {
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
while (i1.hasNext()) {
|
||||
ItemStack stack = i1.next();
|
||||
if (stack.isItemEqual(item))
|
||||
{
|
||||
if (stack.isItemEqual(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -233,9 +203,7 @@ public abstract class Behavior
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean overridesDefault ()
|
||||
{
|
||||
public boolean overridesDefault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,63 +7,72 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorBlockThrow extends Behavior
|
||||
{
|
||||
public class BehaviorBlockThrow extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++) {
|
||||
int direction = par1World.rand.nextInt(8);
|
||||
double speed = 2D * Math.random() + 0.01D;
|
||||
double upVecReduction = 0.25D;
|
||||
double randomnessFactor = 0.5D;
|
||||
double vec0 = 0, vec1 = par1World.rand.nextDouble() * upVecReduction, vec2 = 0;
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 1:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 2:
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 3:
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 4:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 5:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 6:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 7:
|
||||
vec0 = -speed;
|
||||
vec2 = -speed;
|
||||
break;
|
||||
default:
|
||||
vec0 = speed;
|
||||
break;
|
||||
switch (direction) {
|
||||
case 0:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 1:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 2:
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 3:
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 4:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 5:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 6:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 7:
|
||||
vec0 = -speed;
|
||||
vec2 = -speed;
|
||||
break;
|
||||
default:
|
||||
vec0 = speed;
|
||||
break;
|
||||
}
|
||||
|
||||
EntityFallingBlock entityfallingsand = new EntityFallingBlock(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 2F), (double) ((float) par4 + 0.5F), BlockUtils.getBlockFromItemStack(par5ItemStack), par5ItemStack.getItemDamage());
|
||||
EntityFallingBlock entityfallingsand = new EntityFallingBlock(
|
||||
par1World,
|
||||
(double) ((float) par2 + 0.5F),
|
||||
(double) ((float) par3 + 2F),
|
||||
(double) ((float) par4 + 0.5F),
|
||||
BlockUtils.getBlockFromItemStack(par5ItemStack),
|
||||
par5ItemStack.getItemDamage());
|
||||
entityfallingsand.preventEntitySpawning = false;
|
||||
entityfallingsand.ticksExisted = 2;
|
||||
entityfallingsand.motionX = vec0;
|
||||
@@ -74,14 +83,12 @@ public class BehaviorBlockThrow extends Behavior
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackLimit (ItemStack par1ItemStack)
|
||||
{
|
||||
public int getStackLimit(ItemStack par1ItemStack) {
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,19 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.util.DamageSourceLandmine;
|
||||
|
||||
public class BehaviorDefault extends Behavior
|
||||
{
|
||||
public class BehaviorDefault extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
if (triggerer != null)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
if (triggerer != null) {
|
||||
triggerer.attackEntityFrom(new DamageSourceLandmine("Landmine"), 5F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,15 +5,19 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorDummy extends Behavior
|
||||
{
|
||||
public class BehaviorDummy extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
}
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {}
|
||||
}
|
||||
@@ -8,39 +8,43 @@ import net.minecraft.item.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorExplosive extends Behavior
|
||||
{
|
||||
public class BehaviorExplosive extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
float explodeStrenght = 0;
|
||||
if (par5ItemStack.getItem() == Item.getItemFromBlock(Blocks.tnt))
|
||||
{
|
||||
if (par5ItemStack.getItem() == Item.getItemFromBlock(Blocks.tnt)) {
|
||||
explodeStrenght = 4.0F * par5ItemStack.stackSize;
|
||||
}
|
||||
else if (par5ItemStack.getItem() == Items.gunpowder)
|
||||
{
|
||||
} else if (par5ItemStack.getItem() == Items.gunpowder) {
|
||||
explodeStrenght = 0.8F * par5ItemStack.stackSize;
|
||||
}
|
||||
|
||||
par1World.createExplosion(new EntityTNTPrimed(par1World, par2, par3, par4, (EntityLivingBase) null), par2, par3, par4, explodeStrenght, true);
|
||||
par1World.createExplosion(
|
||||
new EntityTNTPrimed(par1World, par2, par3, par4, (EntityLivingBase) null),
|
||||
par2,
|
||||
par3,
|
||||
par4,
|
||||
explodeStrenght,
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInformation (ItemStack par1ItemStack, List par2List)
|
||||
{
|
||||
public void getInformation(ItemStack par1ItemStack, List par2List) {
|
||||
String str = "UNDEFINED";
|
||||
if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.tnt))
|
||||
{
|
||||
if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.tnt)) {
|
||||
str = "medium";
|
||||
}
|
||||
else if (par1ItemStack.getItem() == Items.gunpowder)
|
||||
{
|
||||
} else if (par1ItemStack.getItem() == Items.gunpowder) {
|
||||
str = "small";
|
||||
}
|
||||
|
||||
@@ -49,8 +53,7 @@ public class BehaviorExplosive extends Behavior
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,9 +61,7 @@ public class BehaviorExplosive extends Behavior
|
||||
// Change this to false to greatly decrease the maximum potential of
|
||||
// explosions but at the same time, make them launch the player much
|
||||
// higher(I mean the explosions with 2 or more TNT
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
public boolean effectStacks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,20 +10,24 @@ import net.minecraft.world.World;
|
||||
import tconstruct.mechworks.itemblocks.ItemBlockLandmine;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorFirecharge extends Behavior
|
||||
{
|
||||
public class BehaviorFirecharge extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
EnumFacing face = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
for (int n = 0; n < par5ItemStack.stackSize; n++)
|
||||
{
|
||||
for (int n = 0; n < par5ItemStack.stackSize; n++) {
|
||||
triggerer.attackEntityFrom(DamageSource.generic, 9F);
|
||||
triggerer.setFire(4);
|
||||
double d0 = par2 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
@@ -35,12 +39,13 @@ public class BehaviorFirecharge extends Behavior
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetZ();
|
||||
par1World.spawnEntityInWorld(new EntitySmallFireball(par1World, d0, d1, d2, d3, d4, d5));
|
||||
|
||||
for (int i = par2 - 2; i <= (par2 + 2); i++)
|
||||
{
|
||||
for (int j = par4 - 2; j <= (par4 + 2); j++)
|
||||
{
|
||||
if ((par1World.getBlock(i, par3, j) == null || (par1World.getBlock(i, par3, j) != null && par1World.getBlock(i, par3, j).isReplaceable(par1World, i, par3, j))) && ItemBlockLandmine.getRandom().nextInt(5) == 0 && Blocks.fire.canPlaceBlockAt(par1World, i, par3, j))
|
||||
{
|
||||
for (int i = par2 - 2; i <= (par2 + 2); i++) {
|
||||
for (int j = par4 - 2; j <= (par4 + 2); j++) {
|
||||
if ((par1World.getBlock(i, par3, j) == null
|
||||
|| (par1World.getBlock(i, par3, j) != null
|
||||
&& par1World.getBlock(i, par3, j).isReplaceable(par1World, i, par3, j)))
|
||||
&& ItemBlockLandmine.getRandom().nextInt(5) == 0
|
||||
&& Blocks.fire.canPlaceBlockAt(par1World, i, par3, j)) {
|
||||
par1World.setBlock(i, par3, j, Blocks.fire);
|
||||
}
|
||||
}
|
||||
@@ -49,8 +54,7 @@ public class BehaviorFirecharge extends Behavior
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,53 +8,53 @@ import net.minecraft.world.World;
|
||||
import tconstruct.mechworks.entity.item.EntityLandmineFirework;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorFirework extends Behavior
|
||||
{
|
||||
public class BehaviorFirework extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
EnumFacing facing = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++)
|
||||
{
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++) {
|
||||
// TODO entity registration and stuffs
|
||||
EntityLandmineFirework entityfireworkrocket = new EntityLandmineFirework(par1World, (double) par2, (double) par3, (double) par4, par5ItemStack, facing.ordinal()).setRider(i == 0 ? triggerer : null);
|
||||
EntityLandmineFirework entityfireworkrocket = new EntityLandmineFirework(
|
||||
par1World, (double) par2, (double) par3, (double) par4, par5ItemStack, facing.ordinal())
|
||||
.setRider(i == 0 ? triggerer : null);
|
||||
par1World.spawnEntityInWorld(entityfireworkrocket);
|
||||
|
||||
boolean shouldRun = true;
|
||||
if (triggerer instanceof EntityPlayer)
|
||||
{
|
||||
if (triggerer instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) triggerer;
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
// Remove the bellow comment to make the player in creative
|
||||
// mode not get launched
|
||||
// shouldRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRun)
|
||||
{
|
||||
if (shouldRun) {
|
||||
triggerer.mountEntity(entityfireworkrocket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean overridesDefault ()
|
||||
{
|
||||
public boolean overridesDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,50 +11,47 @@ import net.minecraft.world.World;
|
||||
import tconstruct.mechworks.itemblocks.ItemBlockLandmine;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorPotion extends Behavior
|
||||
{
|
||||
public class BehaviorPotion extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
if (ItemPotion.isSplash(par5ItemStack.getItemDamage()))
|
||||
{
|
||||
par1World.playSoundAtEntity(triggerer, "random.bow", 0.5F, 0.4F / (ItemBlockLandmine.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
if (ItemPotion.isSplash(par5ItemStack.getItemDamage())) {
|
||||
par1World.playSoundAtEntity(
|
||||
triggerer,
|
||||
"random.bow",
|
||||
0.5F,
|
||||
0.4F / (ItemBlockLandmine.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
par1World.spawnEntityInWorld(new EntityPotion(par1World, (EntityLivingBase) triggerer, par5ItemStack));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!par1World.isRemote) {
|
||||
if (triggerer instanceof EntityLivingBase) {
|
||||
par1World.spawnEntityInWorld(
|
||||
new EntityPotion(par1World, (EntityLivingBase) triggerer, par5ItemStack));
|
||||
} else {
|
||||
par1World.spawnEntityInWorld(new EntityPotion(par1World, par2, par3, par4, par5ItemStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (triggerer instanceof EntityPlayer)
|
||||
{
|
||||
} else {
|
||||
if (triggerer instanceof EntityPlayer) {
|
||||
Items.potionitem.onEaten(par5ItemStack, par1World, (EntityPlayer) triggerer);
|
||||
}
|
||||
else if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
} else if (triggerer instanceof EntityLivingBase) {
|
||||
if (!par1World.isRemote) {
|
||||
List list = Items.potionitem.getEffects(par5ItemStack);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
if (list != null) {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
PotionEffect potioneffect = (PotionEffect) iterator.next();
|
||||
((EntityLivingBase) triggerer).addPotionEffect(new PotionEffect(potioneffect));
|
||||
}
|
||||
@@ -65,8 +62,7 @@ public class BehaviorPotion extends Behavior
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,36 +4,35 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BehaviorPreventExplode extends Behavior
|
||||
{
|
||||
public class BehaviorPreventExplode extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
}
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {}
|
||||
|
||||
@Override
|
||||
public boolean isBehaviorExchangableWithOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isBehaviorExchangableWithOffensive(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesBehaviorPreventRemovalOfBlock (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean doesBehaviorPreventRemovalOfBlock(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockBeRemoved)
|
||||
{
|
||||
public boolean shouldItemBeRemoved(ItemStack par1ItemStack, boolean willBlockBeRemoved) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,48 +9,49 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorProjectile extends Behavior
|
||||
{
|
||||
public class BehaviorProjectile extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
IProjectile entity = null;
|
||||
|
||||
EnumFacing enumfacing = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
if (par5ItemStack.getItem() == Items.arrow)
|
||||
{
|
||||
if (par5ItemStack.getItem() == Items.arrow) {
|
||||
entity = new EntityArrow(par1World, par2, par3, par4);
|
||||
((EntityArrow) entity).canBePickedUp = 1;
|
||||
}
|
||||
else if (par5ItemStack.getItem() == Items.snowball)
|
||||
{
|
||||
} else if (par5ItemStack.getItem() == Items.snowball) {
|
||||
entity = new EntitySnowball(par1World, par2, par3, par4);
|
||||
}
|
||||
else if (par5ItemStack.getItem() == Items.ender_pearl)
|
||||
{
|
||||
if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
} else if (par5ItemStack.getItem() == Items.ender_pearl) {
|
||||
if (triggerer instanceof EntityLivingBase) {
|
||||
entity = new EntityEnderPearl(par1World, (EntityLivingBase) triggerer);
|
||||
((EntityEnderPearl) entity).setPosition(par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
entity = new EntityEnderPearl(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), 1.1F, 6.0F);
|
||||
entity.setThrowableHeading(
|
||||
(double) enumfacing.getFrontOffsetX(),
|
||||
(double) ((float) enumfacing.getFrontOffsetY() + 0.1F),
|
||||
(double) enumfacing.getFrontOffsetZ(),
|
||||
1.1F,
|
||||
6.0F);
|
||||
par1World.spawnEntityInWorld((Entity) entity);
|
||||
par1World.playAuxSFX(1002, par2, par3, par4, 0);
|
||||
}
|
||||
@@ -58,9 +59,7 @@ public class BehaviorProjectile extends Behavior
|
||||
// Projectiles: snowballs, arrows
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,49 +10,54 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import tconstruct.mechworks.itemblocks.ItemBlockLandmine;
|
||||
|
||||
//TODO Add a block that is similar to landmine, but only triggers by redstone, does not hurt the player, and does not disappear when used(also does not do anything that can deal damage)
|
||||
// TODO Add a block that is similar to landmine, but only triggers by redstone, does not hurt the player, and does not
|
||||
// disappear when used(also does not do anything that can deal damage)
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorShears extends Behavior
|
||||
{
|
||||
public class BehaviorShears extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
Random rand = ItemBlockLandmine.getRandom();
|
||||
|
||||
List<IShearable> sheeps = par1World.getEntitiesWithinAABB(IShearable.class, AxisAlignedBB.getBoundingBox(par2 - 2, par3 - 2, par4 - 2, par2 + 2, par3 + 2, par4 + 2));
|
||||
List<IShearable> sheeps = par1World.getEntitiesWithinAABB(
|
||||
IShearable.class,
|
||||
AxisAlignedBB.getBoundingBox(par2 - 2, par3 - 2, par4 - 2, par2 + 2, par3 + 2, par4 + 2));
|
||||
|
||||
if (sheeps != null && !sheeps.isEmpty())
|
||||
{
|
||||
if (sheeps != null && !sheeps.isEmpty()) {
|
||||
Iterator<IShearable> i1 = sheeps.iterator();
|
||||
IShearable sheep;
|
||||
while (i1.hasNext())
|
||||
{
|
||||
while (i1.hasNext()) {
|
||||
sheep = i1.next();
|
||||
if (sheep.isShearable(par5ItemStack, par1World, par2, par3, par4))
|
||||
{
|
||||
if (rand.nextInt(2) == 0)
|
||||
{
|
||||
ArrayList<ItemStack> drops = sheep.onSheared(par5ItemStack, par1World, par2, par3, par4, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, par5ItemStack));
|
||||
if (sheep instanceof EntityLivingBase)
|
||||
{
|
||||
if (sheep.isShearable(par5ItemStack, par1World, par2, par3, par4)) {
|
||||
if (rand.nextInt(2) == 0) {
|
||||
ArrayList<ItemStack> drops = sheep.onSheared(
|
||||
par5ItemStack,
|
||||
par1World,
|
||||
par2,
|
||||
par3,
|
||||
par4,
|
||||
EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, par5ItemStack));
|
||||
if (sheep instanceof EntityLivingBase) {
|
||||
par5ItemStack.damageItem(1, (EntityLivingBase) sheep);
|
||||
}
|
||||
Iterator<ItemStack> i2 = drops.iterator();
|
||||
while (i2.hasNext())
|
||||
{
|
||||
if (sheep instanceof Entity)
|
||||
{
|
||||
while (i2.hasNext()) {
|
||||
if (sheep instanceof Entity) {
|
||||
Entity ent = (Entity) sheep;
|
||||
dropItem(par1World, (int) ent.posX, (int) ent.posY, (int) ent.posZ, i2.next());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dropItem(par1World, par2, par3, par4, i2.next());
|
||||
}
|
||||
}
|
||||
@@ -61,21 +66,19 @@ public class BehaviorShears extends Behavior
|
||||
}
|
||||
}
|
||||
|
||||
if (willBlockBeRemoved)
|
||||
{
|
||||
if (willBlockBeRemoved) {
|
||||
dropItem(par1World, par2, par3, par4, par5ItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
protected void dropItem (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack)
|
||||
{
|
||||
if (!par1World.isRemote && par1World.getGameRules().getGameRuleBooleanValue("doTileDrops"))
|
||||
{
|
||||
protected void dropItem(World par1World, int par2, int par3, int par4, ItemStack par5ItemStack) {
|
||||
if (!par1World.isRemote && par1World.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (par1World.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (par1World.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d2 = (double) (par1World.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) par2 + d0, (double) par3 + d1, (double) par4 + d2, par5ItemStack);
|
||||
EntityItem entityitem = new EntityItem(
|
||||
par1World, (double) par2 + d0, (double) par3 + d1, (double) par4 + d2, par5ItemStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
@@ -84,21 +87,17 @@ public class BehaviorShears extends Behavior
|
||||
// Shear some sheep around a small area
|
||||
|
||||
@Override
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockBeRemoved)
|
||||
{
|
||||
public boolean shouldItemBeRemoved(ItemStack par1ItemStack, boolean willBlockBeRemoved) {
|
||||
return willBlockBeRemoved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
public boolean effectStacks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,38 +6,39 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorSpawnEgg extends Behavior
|
||||
{
|
||||
public class BehaviorSpawnEgg extends Behavior {
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
public void executeLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
ItemStack par5ItemStack,
|
||||
Entity triggerer,
|
||||
boolean willBlockBeRemoved) {
|
||||
EnumFacing enumfacing = getFacing(par1World, par2, par3, par4);
|
||||
double d0 = par2 + Math.random() + (double) enumfacing.getFrontOffsetX();
|
||||
double d1 = (double) ((float) par3 + 0.2F);
|
||||
double d2 = par4 + Math.random() + (double) enumfacing.getFrontOffsetZ();
|
||||
Entity entity = ItemMonsterPlacer.spawnCreature(par1World, par5ItemStack.getItemDamage(), d0, d1, d2);
|
||||
|
||||
if (entity instanceof EntityLivingBase && par5ItemStack.hasDisplayName())
|
||||
{
|
||||
if (entity instanceof EntityLivingBase && par5ItemStack.hasDisplayName()) {
|
||||
((EntityLiving) entity).setCustomNameTag(par5ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
public boolean effectStacks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isOffensive(ItemStack par1ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+34
-50
@@ -11,97 +11,81 @@ import tconstruct.mechworks.landmine.behavior.Behavior;
|
||||
import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class SpecialStackHandler
|
||||
{
|
||||
public abstract class SpecialStackHandler {
|
||||
|
||||
public static ArrayList<SpecialStackHandler> handlers = new ArrayList<SpecialStackHandler>();
|
||||
|
||||
public static void registerBuiltInStackHandlers ()
|
||||
{
|
||||
public static void registerBuiltInStackHandlers() {
|
||||
addSpecialBehavior(new SpecialStackHandlerRocketFireball());
|
||||
}
|
||||
|
||||
public static void addSpecialBehavior (SpecialStackHandler handler)
|
||||
{
|
||||
if (!handlers.contains(handler))
|
||||
{
|
||||
public static void addSpecialBehavior(SpecialStackHandler handler) {
|
||||
if (!handlers.contains(handler)) {
|
||||
handlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void checkStack (World par1World, int par2, int par3, int par4, Entity triggerer, ArrayList<ItemStack> stacks);
|
||||
public abstract void checkStack(
|
||||
World par1World, int par2, int par3, int par4, Entity triggerer, ArrayList<ItemStack> stacks);
|
||||
|
||||
public EnumFacing getFacing (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
public EnumFacing getFacing(World par1World, int par2, int par3, int par4) {
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(par1World.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return EnumFacing.UP;
|
||||
case UP:
|
||||
return EnumFacing.DOWN;
|
||||
case WEST:
|
||||
return EnumFacing.WEST;
|
||||
case EAST:
|
||||
return EnumFacing.EAST;
|
||||
case SOUTH:
|
||||
return EnumFacing.NORTH;
|
||||
case NORTH:
|
||||
return EnumFacing.SOUTH;
|
||||
default:
|
||||
return EnumFacing.UP;
|
||||
switch (dir) {
|
||||
case DOWN:
|
||||
return EnumFacing.UP;
|
||||
case UP:
|
||||
return EnumFacing.DOWN;
|
||||
case WEST:
|
||||
return EnumFacing.WEST;
|
||||
case EAST:
|
||||
return EnumFacing.EAST;
|
||||
case SOUTH:
|
||||
return EnumFacing.NORTH;
|
||||
case NORTH:
|
||||
return EnumFacing.SOUTH;
|
||||
default:
|
||||
return EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
|
||||
public final void removeItemFromInventory (World par1World, int x, int y, int z, ItemStack item)
|
||||
{
|
||||
if (item == null || item.stackSize <= 0)
|
||||
{
|
||||
public final void removeItemFromInventory(World par1World, int x, int y, int z, ItemStack item) {
|
||||
if (item == null || item.stackSize <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntityLandmine tileEntity = (TileEntityLandmine) par1World.getTileEntity(x, y, z);
|
||||
|
||||
while (item.stackSize > 0)
|
||||
{
|
||||
while (item.stackSize > 0) {
|
||||
boolean hasRemovedThisIteration = false;
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
if (!hasRemovedThisIteration && tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(item))
|
||||
{
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++) {
|
||||
if (!hasRemovedThisIteration && tileEntity.getStackInSlot(i) != null) {
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(item)) {
|
||||
tileEntity.decrStackSize(i, 1);
|
||||
item.stackSize--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRemovedThisIteration && i == tileEntity.getSizeTriggerInventory() - 1)
|
||||
{
|
||||
if (!hasRemovedThisIteration && i == tileEntity.getSizeTriggerInventory() - 1) {
|
||||
item.stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final int arrayIndexOfStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
public static final int arrayIndexOfStack(ArrayList<ItemStack> stacks, ItemStack item) {
|
||||
return Behavior.arrayIndexOfStack(stacks, item);
|
||||
}
|
||||
|
||||
public static final boolean arrayContainsEqualStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
public static final boolean arrayContainsEqualStack(ArrayList<ItemStack> stacks, ItemStack item) {
|
||||
return Behavior.arrayContainsEqualStack(stacks, item);
|
||||
}
|
||||
|
||||
public boolean isOffensive (ArrayList<ItemStack> par1ArrayList)
|
||||
{
|
||||
public boolean isOffensive(ArrayList<ItemStack> par1ArrayList) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+11
-18
@@ -9,25 +9,22 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SpecialStackHandlerRocketFireball extends SpecialStackHandler
|
||||
{
|
||||
public class SpecialStackHandlerRocketFireball extends SpecialStackHandler {
|
||||
|
||||
@Override
|
||||
public void checkStack (World par1World, int par2, int par3, int par4, Entity triggerer, ArrayList<ItemStack> stacks)
|
||||
{
|
||||
if (stacks.isEmpty())
|
||||
{
|
||||
public void checkStack(
|
||||
World par1World, int par2, int par3, int par4, Entity triggerer, ArrayList<ItemStack> stacks) {
|
||||
if (stacks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.arrayContainsEqualStack(stacks, new ItemStack(Items.fireworks)) && this.arrayContainsEqualStack(stacks, new ItemStack(Items.fire_charge)))
|
||||
{
|
||||
if (this.arrayContainsEqualStack(stacks, new ItemStack(Items.fireworks))
|
||||
&& this.arrayContainsEqualStack(stacks, new ItemStack(Items.fire_charge))) {
|
||||
int index0 = this.arrayIndexOfStack(stacks, new ItemStack(Items.fireworks));
|
||||
int index1 = this.arrayIndexOfStack(stacks, new ItemStack(Items.fire_charge));
|
||||
EnumFacing face = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
while (stacks.get(index0).stackSize > 0 && stacks.get(index1).stackSize > 0)
|
||||
{
|
||||
while (stacks.get(index0).stackSize > 0 && stacks.get(index1).stackSize > 0) {
|
||||
double d0 = par2 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
double d1 = par3 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
double d2 = par4 + (double) ((float) face.getFrontOffsetZ() * 0.3F);
|
||||
@@ -38,22 +35,18 @@ public class SpecialStackHandlerRocketFireball extends SpecialStackHandler
|
||||
EntityFireball fireball = new EntityLargeFireball(par1World, d0, d1, d2, d3, d4, d5);
|
||||
par1World.spawnEntityInWorld(fireball);
|
||||
|
||||
if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
if (triggerer instanceof EntityLivingBase) {
|
||||
boolean shouldRun = true;
|
||||
if (triggerer instanceof EntityPlayer)
|
||||
{
|
||||
if (triggerer instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) triggerer;
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
// Remove the bellow comment to make the player in
|
||||
// creative mode not get launched
|
||||
// shouldRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRun)
|
||||
{
|
||||
if (shouldRun) {
|
||||
triggerer.mountEntity(fireball);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,20 +10,18 @@ import tconstruct.mechworks.landmine.behavior.Behavior;
|
||||
/**
|
||||
* This logic is designed only for blocks having TileEntityLandmine as their
|
||||
* tileEntity(otherwise ClassCastException will be awarded)
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class LandmineExplodeLogic
|
||||
{
|
||||
public class LandmineExplodeLogic {
|
||||
|
||||
private final World worldObj;
|
||||
private final Entity triggerer;
|
||||
private final TileEntityLandmine tileEntity;
|
||||
private final int x, y, z;
|
||||
|
||||
public LandmineExplodeLogic(World par1World, int par2, int par3, int par4, Entity entity)
|
||||
{
|
||||
public LandmineExplodeLogic(World par1World, int par2, int par3, int par4, Entity entity) {
|
||||
worldObj = par1World;
|
||||
this.tileEntity = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
this.x = par2;
|
||||
@@ -32,10 +30,8 @@ public class LandmineExplodeLogic
|
||||
this.triggerer = entity;
|
||||
}
|
||||
|
||||
public void explode ()
|
||||
{
|
||||
if (triggerer == null)
|
||||
{
|
||||
public void explode() {
|
||||
if (triggerer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,84 +42,63 @@ public class LandmineExplodeLogic
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
boolean hasExploded = false;
|
||||
|
||||
if (tileEntity == null)
|
||||
{
|
||||
if (tileEntity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
tileEntity.isExploding = true;
|
||||
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++) {
|
||||
ItemStack currentStack = tileEntity.getStackInSlot(i);
|
||||
Behavior b = Behavior.getBehaviorFromStack(currentStack);
|
||||
if (b != null)
|
||||
{
|
||||
if (b != null) {
|
||||
|
||||
if (b.doesBehaviorPreventRemovalOfBlock(currentStack))
|
||||
{
|
||||
if (b.doesBehaviorPreventRemovalOfBlock(currentStack)) {
|
||||
preventExplode = true;
|
||||
}
|
||||
|
||||
if (!b.isBehaviorExchangableWithOffensive(currentStack))
|
||||
{
|
||||
if (!b.isBehaviorExchangableWithOffensive(currentStack)) {
|
||||
isOffensive = false;
|
||||
}
|
||||
|
||||
if (b.overridesDefault())
|
||||
{
|
||||
if (b.overridesDefault()) {
|
||||
cancelDefault = true;
|
||||
}
|
||||
|
||||
if (!stacks.isEmpty() && Behavior.arrayContainsEqualStack(stacks, currentStack) && b.effectStacks())
|
||||
{
|
||||
if (!stacks.isEmpty() && Behavior.arrayContainsEqualStack(stacks, currentStack) && b.effectStacks()) {
|
||||
stacks.get(Behavior.arrayIndexOfStack(stacks, currentStack)).stackSize += currentStack.stackSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
stacks.add(currentStack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LandmineSpecialStackLogic specialStacks = new LandmineSpecialStackLogic(worldObj, x, y, z, triggerer, isOffensive, stacks);
|
||||
LandmineSpecialStackLogic specialStacks =
|
||||
new LandmineSpecialStackLogic(worldObj, x, y, z, triggerer, isOffensive, stacks);
|
||||
specialStacks.handleSpecialStacks();
|
||||
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
while (i1.hasNext())
|
||||
{
|
||||
while (i1.hasNext()) {
|
||||
ItemStack currentStack = i1.next();
|
||||
Behavior b = Behavior.getBehaviorFromStack(currentStack);
|
||||
if (b != null)
|
||||
{
|
||||
if (isOffensive || !b.isOffensive(currentStack))
|
||||
{
|
||||
if (b != null) {
|
||||
if (isOffensive || !b.isOffensive(currentStack)) {
|
||||
b.executeLogic(worldObj, x, y, z, currentStack, triggerer, !preventExplode);
|
||||
if (b.shouldItemBeRemoved(currentStack, !preventExplode))
|
||||
{
|
||||
if (b.effectStacks())
|
||||
{
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack))
|
||||
{
|
||||
if (b.shouldItemBeRemoved(currentStack, !preventExplode)) {
|
||||
if (b.effectStacks()) {
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++) {
|
||||
if (tileEntity.getStackInSlot(i) != null) {
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack)) {
|
||||
tileEntity.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
boolean hasRemoved = false;
|
||||
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory() && !hasRemoved; i++)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack))
|
||||
{
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory() && !hasRemoved; i++) {
|
||||
if (tileEntity.getStackInSlot(i) != null) {
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack)) {
|
||||
tileEntity.setInventorySlotContents(i, null);
|
||||
hasRemoved = true;
|
||||
}
|
||||
@@ -136,18 +111,14 @@ public class LandmineExplodeLogic
|
||||
}
|
||||
|
||||
Behavior defBeh = Behavior.getDefaulBehavior();
|
||||
if (defBeh != null && isOffensive && !cancelDefault)
|
||||
{
|
||||
if (defBeh != null && isOffensive && !cancelDefault) {
|
||||
defBeh.executeLogic(worldObj, x, y, z, null, triggerer, !preventExplode);
|
||||
}
|
||||
|
||||
if (hasExploded || defBeh != null && !preventExplode)
|
||||
{
|
||||
if (hasExploded || defBeh != null && !preventExplode) {
|
||||
worldObj.removeTileEntity(x, y, z);
|
||||
WorldHelper.setBlockToAir(worldObj, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tileEntity.isExploding = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.mechworks.landmine.behavior.stackCombo.SpecialStackHandler;
|
||||
|
||||
public class LandmineSpecialStackLogic
|
||||
{
|
||||
public class LandmineSpecialStackLogic {
|
||||
|
||||
private final World worldObj;
|
||||
private final Entity triggerer;
|
||||
@@ -16,8 +15,14 @@ public class LandmineSpecialStackLogic
|
||||
private final boolean isOffensive;
|
||||
private final ArrayList<ItemStack> stackEffects;
|
||||
|
||||
public LandmineSpecialStackLogic(World par1World, int par2, int par3, int par4, Entity entity, boolean mayHurtPlayer, ArrayList<ItemStack> items)
|
||||
{
|
||||
public LandmineSpecialStackLogic(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
Entity entity,
|
||||
boolean mayHurtPlayer,
|
||||
ArrayList<ItemStack> items) {
|
||||
worldObj = par1World;
|
||||
this.tileEntity = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
this.x = par2;
|
||||
@@ -28,18 +33,14 @@ public class LandmineSpecialStackLogic
|
||||
this.stackEffects = items;
|
||||
}
|
||||
|
||||
public void handleSpecialStacks ()
|
||||
{
|
||||
public void handleSpecialStacks() {
|
||||
Iterator<SpecialStackHandler> i1 = SpecialStackHandler.handlers.iterator();
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
while (i1.hasNext()) {
|
||||
SpecialStackHandler h = i1.next();
|
||||
if (isOffensive || !h.isOffensive(stackEffects))
|
||||
{
|
||||
if (isOffensive || !h.isOffensive(stackEffects)) {
|
||||
h.checkStack(worldObj, x, y, z, triggerer, stackEffects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,12 +9,11 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TileEntityLandmine extends TileEntity implements IInventory
|
||||
{
|
||||
public class TileEntityLandmine extends TileEntity implements IInventory {
|
||||
|
||||
private ItemStack[] inventory = new ItemStack[getSizeInventory()];
|
||||
private String containerName;
|
||||
@@ -27,27 +26,22 @@ public class TileEntityLandmine extends TileEntity implements IInventory
|
||||
public int triggerType;
|
||||
public boolean isExploding = false;
|
||||
|
||||
public int getSizeTriggerInventory ()
|
||||
{
|
||||
public int getSizeTriggerInventory() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
public int getSizeInventory() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
for (int i = 0; i < this.inventory.length; ++i) {
|
||||
if (this.inventory[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
this.inventory[i].writeToNBT(nbttagcompound1);
|
||||
@@ -59,183 +53,145 @@ public class TileEntityLandmine extends TileEntity implements IInventory
|
||||
|
||||
par1NBTTagCompound.setInteger("triggerType", triggerType);
|
||||
|
||||
if (this.hasCustomInventoryName())
|
||||
{
|
||||
if (this.hasCustomInventoryName()) {
|
||||
par1NBTTagCompound.setString("CustomName", this.containerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", 10);
|
||||
this.inventory = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.getCompoundTagAt(i);
|
||||
byte b0 = nbttagcompound1.getByte("Slot");
|
||||
|
||||
if (b0 >= 0 && b0 < this.inventory.length)
|
||||
{
|
||||
if (b0 >= 0 && b0 < this.inventory.length) {
|
||||
this.inventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
triggerType = par1NBTTagCompound.getInteger("triggerType");
|
||||
|
||||
if (par1NBTTagCompound.hasKey("CustomName"))
|
||||
{
|
||||
if (par1NBTTagCompound.hasKey("CustomName")) {
|
||||
this.containerName = par1NBTTagCompound.getString("CustomName");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int i)
|
||||
{
|
||||
if (i < inventory.length)
|
||||
{
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if (i < inventory.length) {
|
||||
return inventory[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int par1, int par2)
|
||||
{
|
||||
if (par1 < inventory.length)
|
||||
{
|
||||
if (inventory[par1] != null)
|
||||
{
|
||||
public ItemStack decrStackSize(int par1, int par2) {
|
||||
if (par1 < inventory.length) {
|
||||
if (inventory[par1] != null) {
|
||||
ItemStack itemstack;
|
||||
|
||||
if (inventory[par1].stackSize <= par2)
|
||||
{
|
||||
if (inventory[par1].stackSize <= par2) {
|
||||
itemstack = inventory[par1];
|
||||
inventory[par1] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
itemstack = inventory[par1].splitStack(par2);
|
||||
|
||||
if (inventory[par1].stackSize == 0)
|
||||
{
|
||||
if (inventory[par1].stackSize == 0) {
|
||||
inventory[par1] = null;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int i)
|
||||
{
|
||||
if (i < inventory.length && this.inventory[i] != null)
|
||||
{
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
if (i < inventory.length && this.inventory[i] != null) {
|
||||
ItemStack itemstack = this.inventory[i];
|
||||
this.inventory[i] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int i, ItemStack itemstack)
|
||||
{
|
||||
if (i < inventory.length)
|
||||
{
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if (i < inventory.length) {
|
||||
inventory[i] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomInventoryName() ? this.containerName : "Landmine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return containerName != null && containerName.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void setGuiDisplayName (String par1Str)
|
||||
{
|
||||
public void setGuiDisplayName(String par1Str) {
|
||||
this.containerName = par1Str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
|
||||
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this
|
||||
? false
|
||||
: par1EntityPlayer.getDistanceSq(
|
||||
(double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D)
|
||||
<= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int i, ItemStack itemstack)
|
||||
{
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
// Should automatic camo insertion be allowed.
|
||||
if (i == 3)
|
||||
{
|
||||
if (i == 3) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Here for mDiyo to decide if he wants automation for
|
||||
// insertion/extraction of the items to be an option.
|
||||
// Would be useful for building automated mine laying machines.
|
||||
@@ -243,24 +199,19 @@ public class TileEntityLandmine extends TileEntity implements IInventory
|
||||
}
|
||||
}
|
||||
|
||||
public void setSoundPlayed ()
|
||||
{
|
||||
public void setSoundPlayed() {
|
||||
soundcountythingmax = 35;
|
||||
soundcountything = soundcountythingmax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (shouldUpdateLogic)
|
||||
{
|
||||
public void updateEntity() {
|
||||
if (shouldUpdateLogic) {
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
shouldUpdateLogic = false;
|
||||
}
|
||||
if (soundcountything > 0)
|
||||
{
|
||||
if (soundcountything > 0) {
|
||||
soundcountything--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,20 +11,17 @@ import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.world.entity.CartEntity;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CartRender extends Render
|
||||
{
|
||||
public class CartRender extends Render {
|
||||
protected ModelBase modelCart;
|
||||
RenderBlocks renderblocks;
|
||||
|
||||
public CartRender()
|
||||
{
|
||||
public CartRender() {
|
||||
this.shadowSize = 0.5F;
|
||||
this.modelCart = new ModelPullcart();
|
||||
renderblocks = new RenderBlocks();
|
||||
}
|
||||
|
||||
public void renderPullcart (CartEntity cart, double posX, double posY, double posZ, float par8, float par9)
|
||||
{
|
||||
public void renderPullcart(CartEntity cart, double posX, double posY, double posZ, float par8, float par9) {
|
||||
GL11.glPushMatrix();
|
||||
long var10 = (long) cart.hashCode() * 493286711L;
|
||||
var10 = var10 * var10 * 4392167121L + var10 * 98761L;
|
||||
@@ -39,18 +36,15 @@ public class CartRender extends Render
|
||||
Vec3 var23 = cart.func_70489_a(var15, var17, var19);
|
||||
float var24 = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * par9;
|
||||
|
||||
if (var23 != null)
|
||||
{
|
||||
if (var23 != null) {
|
||||
Vec3 var25 = cart.func_70495_a(var15, var17, var19, var21);
|
||||
Vec3 var26 = cart.func_70495_a(var15, var17, var19, -var21);
|
||||
|
||||
if (var25 == null)
|
||||
{
|
||||
if (var25 == null) {
|
||||
var25 = var23;
|
||||
}
|
||||
|
||||
if (var26 == null)
|
||||
{
|
||||
if (var26 == null) {
|
||||
var26 = var23;
|
||||
}
|
||||
|
||||
@@ -59,8 +53,7 @@ public class CartRender extends Render
|
||||
posZ += var23.zCoord - var19;
|
||||
Vec3 var27 = var26.addVector(-var25.xCoord, -var25.yCoord, -var25.zCoord);
|
||||
|
||||
if (var27.lengthVector() != 0.0D)
|
||||
{
|
||||
if (var27.lengthVector() != 0.0D) {
|
||||
var27 = var27.normalize();
|
||||
par8 = (float) (Math.atan2(var27.zCoord, var27.xCoord) * 180.0D / Math.PI);
|
||||
var24 = (float) (Math.atan(var27.yCoord) * 73.0D);
|
||||
@@ -73,32 +66,30 @@ public class CartRender extends Render
|
||||
float var28 = (float) cart.getRollingAmplitude() - par9;
|
||||
float var30 = (float) cart.getDamage() - par9;
|
||||
|
||||
if (var30 < 0.0F)
|
||||
{
|
||||
if (var30 < 0.0F) {
|
||||
var30 = 0.0F;
|
||||
}
|
||||
|
||||
if (var28 > 0.0F)
|
||||
{
|
||||
GL11.glRotatef(MathHelper.sin(var28) * var28 * var30 / 10.0F * (float) cart.getRollingDirection(), 1.0F, 0.0F, 0.0F);
|
||||
if (var28 > 0.0F) {
|
||||
GL11.glRotatef(
|
||||
MathHelper.sin(var28) * var28 * var30 / 10.0F * (float) cart.getRollingDirection(),
|
||||
1.0F,
|
||||
0.0F,
|
||||
0.0F);
|
||||
}
|
||||
|
||||
if (cart.getCartType() != 0)
|
||||
{
|
||||
if (cart.getCartType() != 0) {
|
||||
// this.loadTexture("/terrain.png");
|
||||
float var29 = 0.75F;
|
||||
GL11.glScalef(var29, var29, var29);
|
||||
|
||||
if (cart.getCartType() == 1)
|
||||
{
|
||||
if (cart.getCartType() == 1) {
|
||||
GL11.glTranslatef(0.0F, 0.5F, 0.0F);
|
||||
renderblocks.renderBlockAsItem(Blocks.chest, 0, cart.getBrightness(par9));
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.5F, 0.0F, -0.5F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else if (cart.getCartType() == 2)
|
||||
{
|
||||
} else if (cart.getCartType() == 2) {
|
||||
GL11.glTranslatef(0.0F, 0.3125F, 0.0F);
|
||||
renderblocks.renderBlockAsItem(Blocks.furnace, 0, cart.getBrightness(par9));
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
@@ -124,14 +115,12 @@ public class CartRender extends Render
|
||||
* f1). But JAD is pre 1.5 so doesn't do that.
|
||||
*/
|
||||
@Override
|
||||
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
|
||||
this.renderPullcart((CartEntity) par1Entity, par2, par4, par6, par8, par9);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture (Entity par1Entity)
|
||||
{
|
||||
protected ResourceLocation getEntityTexture(Entity par1Entity) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ package tconstruct.mechworks.model;
|
||||
import net.minecraft.client.model.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelPullcart extends ModelBase
|
||||
{
|
||||
public class ModelPullcart extends ModelBase {
|
||||
ModelRenderer BackPanel;
|
||||
ModelRenderer FrontPanel;
|
||||
ModelRenderer RightPanel;
|
||||
@@ -47,8 +46,7 @@ public class ModelPullcart extends ModelBase
|
||||
ModelRenderer WheelLeft11;
|
||||
ModelRenderer WheelLeft12;
|
||||
|
||||
public ModelPullcart()
|
||||
{
|
||||
public ModelPullcart() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 64;
|
||||
|
||||
@@ -219,8 +217,7 @@ public class ModelPullcart extends ModelBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render (Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
|
||||
super.render(entity, f, f1, f2, f3, f4, f5);
|
||||
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
BackPanel.render(f5);
|
||||
@@ -266,17 +263,14 @@ public class ModelPullcart extends ModelBase
|
||||
WheelLeft12.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation (ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z) {
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotationAngles (float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
|
||||
{
|
||||
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
|
||||
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,7 @@ package tconstruct.mechworks.model;
|
||||
import net.minecraft.client.model.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelWagon extends ModelBase
|
||||
{
|
||||
public class ModelWagon extends ModelBase {
|
||||
ModelRenderer Bottom;
|
||||
ModelRenderer Left;
|
||||
ModelRenderer Right;
|
||||
@@ -58,8 +57,7 @@ public class ModelWagon extends ModelBase
|
||||
ModelRenderer StandLeft;
|
||||
ModelRenderer StandRight;
|
||||
|
||||
public ModelWagon()
|
||||
{
|
||||
public ModelWagon() {
|
||||
this.textureWidth = 128;
|
||||
this.textureHeight = 64;
|
||||
this.Bottom = new ModelRenderer(this, 26, 46);
|
||||
@@ -380,11 +378,74 @@ public class ModelWagon extends ModelBase
|
||||
* Sets the models various rotation angles then renders the model.
|
||||
*/
|
||||
@Override
|
||||
public void render (Entity var1, float var2, float var3, float var4, float var5, float var6, float var7)
|
||||
{
|
||||
public void render(Entity var1, float var2, float var3, float var4, float var5, float var6, float var7) {
|
||||
super.render(var1, var2, var3, var4, var5, var6, var7);
|
||||
this.setRotationAngles(var2, var3, var4, var5, var6, var7, var1);
|
||||
this.LeftWheelAxle.rotateAngleZ = this.LeftWCenterHbeam.rotateAngleZ = this.LeftWCenterVtop.rotateAngleZ = this.LeftWCenterVbottom.rotateAngleZ = this.LeftWnwH.rotateAngleZ = this.LeftWnwM.rotateAngleZ = this.LeftWnwV.rotateAngleZ = this.LeftWnwEye.rotateAngleZ = this.LeftWneH.rotateAngleZ = this.LeftWneM.rotateAngleZ = this.LeftWneV.rotateAngleZ = this.LeftWneEye.rotateAngleZ = this.LeftWswH.rotateAngleZ = this.LeftWswM.rotateAngleZ = this.LeftWswV.rotateAngleZ = this.LeftWswEye.rotateAngleZ = this.LeftWseH.rotateAngleZ = this.LeftWseM.rotateAngleZ = this.LeftWseV.rotateAngleZ = this.LeftWseEye.rotateAngleZ = this.RightWheelAxle.rotateAngleZ = this.RightWCenterHbeam.rotateAngleZ = this.RightWCenterVtop.rotateAngleZ = this.RightWCenterVbottom.rotateAngleZ = this.RightWnwH.rotateAngleZ = this.RightWnwM.rotateAngleZ = this.RightWnwV.rotateAngleZ = this.RightWnwEye.rotateAngleZ = this.RoghtWneH.rotateAngleZ = this.RightWneM.rotateAngleZ = this.RightWneV.rotateAngleZ = this.RightWneEye.rotateAngleZ = this.RightWswH.rotateAngleZ = this.RightWswM.rotateAngleZ = this.RightWswV.rotateAngleZ = this.RightWswEye.rotateAngleZ = this.RightWseH.rotateAngleZ = this.RightWseM.rotateAngleZ = this.RightWseV.rotateAngleZ = this.RightWseEye.rotateAngleZ;
|
||||
this.LeftWheelAxle.rotateAngleZ = this.LeftWCenterHbeam.rotateAngleZ = this.LeftWCenterVtop.rotateAngleZ =
|
||||
this.LeftWCenterVbottom.rotateAngleZ = this.LeftWnwH.rotateAngleZ = this.LeftWnwM.rotateAngleZ =
|
||||
this.LeftWnwV.rotateAngleZ = this.LeftWnwEye.rotateAngleZ = this.LeftWneH.rotateAngleZ =
|
||||
this.LeftWneM.rotateAngleZ = this.LeftWneV.rotateAngleZ = this.LeftWneEye.rotateAngleZ =
|
||||
this.LeftWswH.rotateAngleZ = this.LeftWswM.rotateAngleZ =
|
||||
this.LeftWswV.rotateAngleZ = this.LeftWswEye.rotateAngleZ =
|
||||
this.LeftWseH.rotateAngleZ = this.LeftWseM.rotateAngleZ =
|
||||
this.LeftWseV.rotateAngleZ =
|
||||
this.LeftWseEye.rotateAngleZ =
|
||||
this.RightWheelAxle.rotateAngleZ =
|
||||
this.RightWCenterHbeam
|
||||
.rotateAngleZ =
|
||||
this.RightWCenterVtop
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWCenterVbottom
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWnwH
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWnwM
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWnwV
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWnwEye
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RoghtWneH
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWneM
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWneV
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWneEye
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWswH
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWswM
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWswV
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWswEye
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWseH
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWseM
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWseV
|
||||
.rotateAngleZ =
|
||||
this
|
||||
.RightWseEye
|
||||
.rotateAngleZ;
|
||||
this.Bottom.render(var7);
|
||||
this.Left.render(var7);
|
||||
this.Right.render(var7);
|
||||
@@ -439,8 +500,7 @@ public class ModelWagon extends ModelBase
|
||||
this.StandRight.render(var7);
|
||||
}
|
||||
|
||||
private void setRotation (ModelRenderer var1, float var2, float var3, float var4)
|
||||
{
|
||||
private void setRotation(ModelRenderer var1, float var2, float var3, float var4) {
|
||||
var1.rotateAngleX = var2;
|
||||
var1.rotateAngleY = var3;
|
||||
var1.rotateAngleZ = var4;
|
||||
@@ -450,8 +510,8 @@ public class ModelWagon extends ModelBase
|
||||
* Sets the models various rotation angles.
|
||||
*/
|
||||
@Override
|
||||
public void setRotationAngles (float var1, float var2, float var3, float var4, float var5, float var6, Entity par7Entity)
|
||||
{
|
||||
public void setRotationAngles(
|
||||
float var1, float var2, float var3, float var4, float var5, float var6, Entity par7Entity) {
|
||||
super.setRotationAngles(var1, var2, var3, var4, var5, var6, par7Entity);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user