mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Fixed a couple of things.
Hopefully all works now. >_>
This commit is contained in:
parent
4144f03d14
commit
e9fa9bca92
4 changed files with 30 additions and 9 deletions
|
@ -76,10 +76,13 @@ public class BlockGiantChest extends BlockContainerBase{
|
||||||
ItemStack[] slots = ((TileEntityGiantChest)tile).slots;
|
ItemStack[] slots = ((TileEntityGiantChest)tile).slots;
|
||||||
|
|
||||||
for(int i = 0; i < list.tagCount(); i++){
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
|
NBTTagCompound compound = list.getCompoundTagAt(i);
|
||||||
|
if(compound != null && compound.hasKey("id")){
|
||||||
slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
|
slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, entity, stack);
|
super.onBlockPlacedBy(world, pos, state, entity, stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,17 @@ public class WorldData{
|
||||||
int dim = world.provider.getDimension();
|
int dim = world.provider.getDimension();
|
||||||
WorldData data = worldData.get(dim);
|
WorldData data = worldData.get(dim);
|
||||||
|
|
||||||
if(data == null && world.isRemote){
|
if(data == null){
|
||||||
data = new WorldData(null, dim);
|
data = new WorldData(null, dim);
|
||||||
|
|
||||||
|
if(world.isRemote){
|
||||||
worldData.put(dim, data);
|
worldData.put(dim, data);
|
||||||
ModUtil.LOGGER.info("Creating temporary WorldData for world "+dim+" on the client!");
|
ModUtil.LOGGER.info("Creating temporary WorldData for world "+dim+" on the client!");
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
ModUtil.LOGGER.warn("Trying to get WorldData from world "+dim+" that doesn't have any data!? This shouldn't happen!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
NBTTagList tagList = compound.getTagList("Items", 10);
|
NBTTagList tagList = compound.getTagList("Items", 10);
|
||||||
for(int i = 0; i < tagList.tagCount(); i++){
|
for(int i = 0; i < tagList.tagCount(); i++){
|
||||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||||
|
if(tagCompound != null && tagCompound.hasKey("id")){
|
||||||
byte slotIndex = tagCompound.getByte("Slot");
|
byte slotIndex = tagCompound.getByte("Slot");
|
||||||
if(slotIndex >= 0 && slotIndex < slots.length){
|
if(slotIndex >= 0 && slotIndex < slots.length){
|
||||||
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||||
|
@ -66,6 +67,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void initializeSlots(int itemAmount){
|
public void initializeSlots(int itemAmount){
|
||||||
this.slots = new ItemStack[itemAmount];
|
this.slots = new ItemStack[itemAmount];
|
||||||
|
|
|
@ -340,8 +340,16 @@ public class WorldUtil{
|
||||||
* @return If the Block could be harvested normally (so that it drops an item)
|
* @return If the Block could be harvested normally (so that it drops an item)
|
||||||
*/
|
*/
|
||||||
public static boolean playerHarvestBlock(World world, BlockPos pos, EntityPlayer player){
|
public static boolean playerHarvestBlock(World world, BlockPos pos, EntityPlayer player){
|
||||||
Block block = PosUtil.getBlock(pos, world);
|
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
if(state == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = state.getBlock();
|
||||||
|
if(block == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
|
|
||||||
|
@ -351,7 +359,8 @@ public class WorldUtil{
|
||||||
//Send Block Breaking Event
|
//Send Block Breaking Event
|
||||||
int xp = -1;
|
int xp = -1;
|
||||||
if(player instanceof EntityPlayerMP){
|
if(player instanceof EntityPlayerMP){
|
||||||
xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)player).interactionManager.getGameType(), (EntityPlayerMP)player, pos);
|
EntityPlayerMP playerMP = (EntityPlayerMP)player;
|
||||||
|
xp = ForgeHooks.onBlockBreakEvent(world, playerMP.interactionManager.getGameType(), playerMP, pos);
|
||||||
if(xp == -1){
|
if(xp == -1){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -397,6 +406,7 @@ public class WorldUtil{
|
||||||
//Check the Server if a Block that changed on the Client really changed, if not, revert the change
|
//Check the Server if a Block that changed on the Client really changed, if not, revert the change
|
||||||
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||||
}
|
}
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue