fixed crates losing locks when mined, connected textures for glasses

This commit is contained in:
Bob 2021-10-09 18:31:49 +02:00
parent 6cde27e91d
commit 9b32f81883
10 changed files with 105 additions and 30 deletions

View File

@ -1569,13 +1569,13 @@ public class ModBlocks {
sand_quartz = new BlockFalling(Material.sand).setBlockName("sand_quartz").setStepSound(Block.soundTypeSand).setCreativeTab(MainRegistry.machineTab).setHardness(0.5F).setBlockTextureName(RefStrings.MODID + ":sand_quartz");
sand_gold = new BlockGoldSand(Material.sand).setBlockName("sand_gold").setStepSound(Block.soundTypeSand).setCreativeTab(MainRegistry.machineTab).setHardness(0.5F).setBlockTextureName(RefStrings.MODID + ":sand_gold");
sand_gold198 = new BlockGoldSand(Material.sand).setBlockName("sand_gold198").setStepSound(Block.soundTypeSand).setCreativeTab(MainRegistry.machineTab).setHardness(0.5F).setBlockTextureName(RefStrings.MODID + ":sand_gold");
glass_boron = new BlockNTMGlass(0, RefStrings.MODID + ":glass_boron", Material.glass).setBlockName("glass_boron").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_lead = new BlockNTMGlass(0, RefStrings.MODID + ":glass_lead", Material.glass).setBlockName("glass_lead").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_uranium = new BlockNTMGlass(1, RefStrings.MODID + ":glass_uranium", Material.glass).setBlockName("glass_uranium").setLightLevel(5F/15F).setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_trinitite = new BlockNTMGlass(1, RefStrings.MODID + ":glass_trinitite", Material.glass).setBlockName("glass_trinitite").setLightLevel(5F/15F).setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_polonium = new BlockNTMGlass(1, RefStrings.MODID + ":glass_polonium", Material.glass).setBlockName("glass_polonium").setLightLevel(5F/15F).setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_ash = new BlockNTMGlass(1, RefStrings.MODID + ":glass_ash", Material.glass).setBlockName("glass_ash").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(3F);
glass_quartz = new BlockNTMGlass(0, RefStrings.MODID + ":glass_quartz", Material.packedIce, true).setBlockName("glass_quartz").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGlass).setHardness(1.0F).setResistance(40.0F).setBlockTextureName(RefStrings.MODID + "glass_quartz");
glass_boron = new BlockNTMGlassCT(0, RefStrings.MODID + ":glass_boron", Material.glass).setBlockName("glass_boron").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_lead = new BlockNTMGlassCT(0, RefStrings.MODID + ":glass_lead", Material.glass).setBlockName("glass_lead").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_uranium = new BlockNTMGlassCT(1, RefStrings.MODID + ":glass_uranium", Material.glass).setBlockName("glass_uranium").setLightLevel(5F/15F).setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_trinitite = new BlockNTMGlassCT(1, RefStrings.MODID + ":glass_trinitite", Material.glass).setBlockName("glass_trinitite").setLightLevel(5F/15F).setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_polonium = new BlockNTMGlassCT(1, RefStrings.MODID + ":glass_polonium", Material.glass).setBlockName("glass_polonium").setLightLevel(5F/15F).setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(0.3F);
glass_ash = new BlockNTMGlassCT(1, RefStrings.MODID + ":glass_ash", Material.glass).setBlockName("glass_ash").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.machineTab).setHardness(3F);
glass_quartz = new BlockNTMGlassCT(0, RefStrings.MODID + ":glass_quartz", Material.packedIce, true).setBlockName("glass_quartz").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGlass).setHardness(1.0F).setResistance(40.0F).setBlockTextureName(RefStrings.MODID + "glass_quartz");
mush = new BlockMush(Material.plants).setBlockName("mush").setCreativeTab(MainRegistry.blockTab).setLightLevel(0.5F).setStepSound(Block.soundTypeGrass).setBlockTextureName(RefStrings.MODID + ":mush");
mush_block = new BlockMushHuge(Material.plants).setBlockName("mush_block").setLightLevel(1.0F).setStepSound(Block.soundTypeGrass).setHardness(0.2F).setBlockTextureName(RefStrings.MODID + ":mush_block_skin");

View File

@ -1,7 +1,5 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
@ -36,8 +34,6 @@ import net.minecraft.world.World;
public class BlockStorageCrate extends BlockContainer {
private final Random field_149933_a = new Random();
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@ -88,33 +84,51 @@ public class BlockStorageCrate extends BlockContainer {
return new TileEntitySafe();
return null;
}
private static boolean dropInv = true;
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drops = new ArrayList();
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
ItemStack drop = new ItemStack(this);
ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z);
if(inv != null) {
drop.stackTagCompound = new NBTTagCompound();
if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) {
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack drop = new ItemStack(this);
ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z);
NBTTagCompound nbt = new NBTTagCompound();
if(inv != null) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == null)
continue;
NBTTagCompound slot = new NBTTagCompound();
stack.writeToNBT(slot);
drop.stackTagCompound.setTag("slot" + i, slot);
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == null)
continue;
NBTTagCompound slot = new NBTTagCompound();
stack.writeToNBT(slot);
nbt.setTag("slot" + i, slot);
}
}
if(inv instanceof TileEntityLockableBase) {
TileEntityLockableBase lockable = (TileEntityLockableBase) inv;
nbt.setInteger("lock", lockable.getPins());
nbt.setDouble("lockMod", lockable.getMod());
}
if(!nbt.hasNoTags()) {
drop.stackTagCompound = nbt;
}
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
}
drops.add(drop);
dropInv = false;
boolean flag = world.setBlockToAir(x, y, z);
dropInv = true;
return drops;
return flag;
}
@Override
@ -154,6 +168,16 @@ public class BlockStorageCrate extends BlockContainer {
for(int i = 0; i < inv.getSizeInventory(); i++) {
inv.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i)));
}
if(inv instanceof TileEntityLockableBase) {
TileEntityLockableBase lockable = (TileEntityLockableBase) inv;
if(stack.stackTagCompound.hasKey("lock")) {
lockable.setPins(stack.stackTagCompound.getInteger("lock"));
lockable.setMod(stack.stackTagCompound.getDouble("lockMod"));
lockable.lock();
}
}
}
if(this != ModBlocks.safe)
@ -174,4 +198,55 @@ public class BlockStorageCrate extends BlockContainer {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(dropInv) {
ISidedInventory sided = (ISidedInventory) world.getTileEntity(x, y, z);
Random rand = world.rand;
if(sided != null) {
for(int i1 = 0; i1 < sided.getSizeInventory(); ++i1) {
ItemStack itemstack = sided.getStackInSlot(i1);
if(itemstack != null) {
float f = rand.nextFloat() * 0.8F + 0.1F;
float f1 = rand.nextFloat() * 0.8F + 0.1F;
float f2 = rand.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0) {
int j1 = rand.nextInt(21) + 10;
if(j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float) rand.nextGaussian() * f3;
entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B