mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 06:53:24 +00:00
Merge pull request #1846 from MatthiasMann/wireless_nbt
let the wireless charger keep it's stored energy when picked up
This commit is contained in:
commit
ba0fe8a0a2
1 file changed
+28
-4
@@ -1,8 +1,9 @@
|
||||
package crazypants.enderio.machine.wireless;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -11,11 +12,9 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.api.tool.ITool;
|
||||
import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockWirelessCharger extends BlockEio implements IResourceTooltipProvider /* IGuiHandler */{
|
||||
|
||||
@@ -104,4 +103,29 @@ public class BlockWirelessCharger extends BlockEio implements IResourceTooltipPr
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doNormalDrops(World world, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
|
||||
if(stack.stackTagCompound != null) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileWirelessCharger) {
|
||||
((TileWirelessCharger) te).readCustomNBT(stack.stackTagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processDrop(World world, int x, int y, int z, TileEntityEio te, ItemStack drop) {
|
||||
drop.stackTagCompound = new NBTTagCompound();
|
||||
if(te instanceof TileWirelessCharger) {
|
||||
((TileWirelessCharger) te).writeCustomNBT(drop.stackTagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user