magnetize magnet
This commit is contained in:
@@ -31,61 +31,35 @@ import appeng.core.AEConfig;
|
|||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.core.sync.GuiBridge;
|
import appeng.core.sync.GuiBridge;
|
||||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||||
|
import appeng.parts.automation.StackUpgradeInventory;
|
||||||
import appeng.util.ConfigManager;
|
import appeng.util.ConfigManager;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ToolWirelessCraftingTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
public class ToolWirelessCraftingTerminal extends ToolWirelessTerminal implements IWirelessTermHandler {
|
||||||
|
|
||||||
public ToolWirelessCraftingTerminal() {
|
public ToolWirelessCraftingTerminal() {
|
||||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
super();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
|
||||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public boolean isFull3D() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
|
||||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
|
||||||
|
|
||||||
if (stack.hasTagCompound()) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
|
||||||
if (tag != null) {
|
|
||||||
final String encKey = tag.getString("encryptionKey");
|
|
||||||
|
|
||||||
if (encKey == null || encKey.isEmpty()) {
|
|
||||||
lines.add(GuiText.Unlinked.getLocal());
|
|
||||||
} else {
|
|
||||||
lines.add(GuiText.Linked.getLocal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,50 +67,6 @@ public class ToolWirelessCraftingTerminal extends AEBasePoweredItem implements I
|
|||||||
return AEApi.instance().definitions().items().wirelessCraftingTerminal().isSameAs(is);
|
return AEApi.instance().definitions().items().wirelessCraftingTerminal().isSameAs(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
|
||||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
|
||||||
return this.getAECurrentPower(is) >= amt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConfigManager getConfigManager(final ItemStack target) {
|
|
||||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
|
||||||
{
|
|
||||||
final NBTTagCompound data = Platform.openNbtData(target);
|
|
||||||
manager.writeToNBT(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
|
||||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
|
||||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
|
||||||
|
|
||||||
out.readFromNBT(Platform.openNbtData(target).copy());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncryptionKey(final ItemStack item) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
|
||||||
return tag.getString("encryptionKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
|
||||||
tag.setString("encryptionKey", encKey);
|
|
||||||
tag.setString("name", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
|
||||||
return slotChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||||
return GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL;
|
return GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL;
|
||||||
|
|||||||
@@ -49,43 +49,10 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ToolWirelessFluidTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
public class ToolWirelessFluidTerminal extends ToolWirelessTerminal implements IWirelessTermHandler {
|
||||||
|
|
||||||
public ToolWirelessFluidTerminal() {
|
public ToolWirelessFluidTerminal() {
|
||||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
super();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
|
||||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public boolean isFull3D() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
|
||||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
|
||||||
|
|
||||||
if (stack.hasTagCompound()) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
|
||||||
if (tag != null) {
|
|
||||||
final String encKey = tag.getString("encryptionKey");
|
|
||||||
|
|
||||||
if (encKey == null || encKey.isEmpty()) {
|
|
||||||
lines.add(GuiText.Unlinked.getLocal());
|
|
||||||
} else {
|
|
||||||
lines.add(GuiText.Linked.getLocal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,50 +60,6 @@ public class ToolWirelessFluidTerminal extends AEBasePoweredItem implements IWir
|
|||||||
return AEApi.instance().definitions().items().wirelessFluidTerminal().isSameAs(is);
|
return AEApi.instance().definitions().items().wirelessFluidTerminal().isSameAs(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
|
||||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
|
||||||
return this.getAECurrentPower(is) >= amt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConfigManager getConfigManager(final ItemStack target) {
|
|
||||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
|
||||||
{
|
|
||||||
final NBTTagCompound data = Platform.openNbtData(target);
|
|
||||||
manager.writeToNBT(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
|
||||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
|
||||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
|
||||||
|
|
||||||
out.readFromNBT(Platform.openNbtData(target).copy());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncryptionKey(final ItemStack item) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
|
||||||
return tag.getString("encryptionKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
|
||||||
tag.setString("encryptionKey", encKey);
|
|
||||||
tag.setString("name", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
|
||||||
return slotChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||||
return GuiBridge.GUI_WIRELESS_FLUID_TERMINAL;
|
return GuiBridge.GUI_WIRELESS_FLUID_TERMINAL;
|
||||||
|
|||||||
@@ -49,43 +49,10 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ToolWirelessPatternTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
public class ToolWirelessPatternTerminal extends ToolWirelessTerminal implements IWirelessTermHandler {
|
||||||
|
|
||||||
public ToolWirelessPatternTerminal() {
|
public ToolWirelessPatternTerminal() {
|
||||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
super();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
|
||||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public boolean isFull3D() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
|
||||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
|
||||||
|
|
||||||
if (stack.hasTagCompound()) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
|
||||||
if (tag != null) {
|
|
||||||
final String encKey = tag.getString("encryptionKey");
|
|
||||||
|
|
||||||
if (encKey == null || encKey.isEmpty()) {
|
|
||||||
lines.add(GuiText.Unlinked.getLocal());
|
|
||||||
} else {
|
|
||||||
lines.add(GuiText.Linked.getLocal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,50 +60,6 @@ public class ToolWirelessPatternTerminal extends AEBasePoweredItem implements IW
|
|||||||
return AEApi.instance().definitions().items().wirelessPatternTerminal().isSameAs(is);
|
return AEApi.instance().definitions().items().wirelessPatternTerminal().isSameAs(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
|
||||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
|
||||||
return this.getAECurrentPower(is) >= amt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConfigManager getConfigManager(final ItemStack target) {
|
|
||||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
|
||||||
{
|
|
||||||
final NBTTagCompound data = Platform.openNbtData(target);
|
|
||||||
manager.writeToNBT(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
|
||||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
|
||||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
|
||||||
|
|
||||||
out.readFromNBT(Platform.openNbtData(target).copy());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncryptionKey(final ItemStack item) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
|
||||||
return tag.getString("encryptionKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
|
||||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
|
||||||
tag.setString("encryptionKey", encKey);
|
|
||||||
tag.setString("name", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
|
||||||
return slotChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||||
return GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL;
|
return GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL;
|
||||||
|
|||||||
@@ -30,23 +30,30 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
|||||||
import appeng.util.ConfigManager;
|
import appeng.util.ConfigManager;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||||
|
|
||||||
|
int magnetTick;
|
||||||
|
|
||||||
public ToolWirelessTerminal() {
|
public ToolWirelessTerminal() {
|
||||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
super(AEConfig.instance().getWirelessTerminalBattery());
|
||||||
}
|
}
|
||||||
@@ -133,6 +140,33 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
|||||||
return slotChanged;
|
return slotChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||||
|
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
|
||||||
|
if (entityIn instanceof EntityPlayer) {
|
||||||
|
this.magnetTick++;
|
||||||
|
if (magnetTick % 5 != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
magnetTick = 0;
|
||||||
|
if (!entityIn.isSneaking()) {
|
||||||
|
NBTTagCompound upgradeNBT = Platform.openNbtData(stack).getCompoundTag("upgrades");
|
||||||
|
ItemStackHandler siu = new ItemStackHandler(0);
|
||||||
|
siu.deserializeNBT(upgradeNBT);
|
||||||
|
for (int s = 0; s < siu.getSlots(); s++) {
|
||||||
|
if (siu.getStackInSlot(s).isItemEqual(AEApi.instance().definitions().materials().cardMagnet().maybeStack(1).get())) {
|
||||||
|
List<EntityItem> ei = worldIn.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(
|
||||||
|
new Vec3d(entityIn.posX + 5, entityIn.posY + 5, entityIn.posZ + 5),
|
||||||
|
new Vec3d(entityIn.posX - 5, entityIn.posY - 5, entityIn.posZ - 5)));
|
||||||
|
for (EntityItem i : ei) {
|
||||||
|
i.setPosition(entityIn.posX, entityIn.posY, entityIn.posZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||||
return GuiBridge.GUI_WIRELESS_TERM;
|
return GuiBridge.GUI_WIRELESS_TERM;
|
||||||
|
|||||||
Reference in New Issue
Block a user