mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
feat: ported bat wings, solidified experience, resonant rice, probe
This commit is contained in:
parent
2419a0e860
commit
c87bfb6c94
10 changed files with 303 additions and 333 deletions
|
@ -242,4 +242,8 @@ public final class ActuallyItems {
|
||||||
public static Item.Properties defaultProps() {
|
public static Item.Properties defaultProps() {
|
||||||
return new Item.Properties().group(ActuallyAdditions.GROUP);
|
return new Item.Properties().group(ActuallyAdditions.GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Item.Properties defaultNonStacking() {
|
||||||
|
return defaultProps().maxStackSize(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -46,7 +46,7 @@ public class ItemLaserWrench extends ItemBase {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (ItemPhantomConnector.getStoredPosition(stack) == null) {
|
if (ItemPhantomConnector.getStoredPosition(stack) == null) {
|
||||||
ItemPhantomConnector.storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
|
ItemPhantomConnector.storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
|
||||||
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.stored.desc"), true);
|
player.sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".laser.stored.desc"), true);
|
||||||
} else {
|
} else {
|
||||||
BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
||||||
if (savedPos != null) {
|
if (savedPos != null) {
|
||||||
|
@ -57,19 +57,19 @@ public class ItemLaserWrench extends ItemBase {
|
||||||
|
|
||||||
int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange());
|
int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange());
|
||||||
int range = lowestRange * lowestRange;
|
int range = lowestRange * lowestRange;
|
||||||
if (ItemPhantomConnector.getStoredWorld(stack) == world && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)) {
|
if (ItemPhantomConnector.getStoredWorld(stack) == world.getDimensionKey() && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)) {
|
||||||
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
||||||
|
|
||||||
((TileEntityLaserRelay) savedTile).sendUpdate();
|
((TileEntityLaserRelay) savedTile).sendUpdate();
|
||||||
relay.sendUpdate();
|
relay.sendUpdate();
|
||||||
|
|
||||||
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.connected.desc"), true);
|
player.sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".laser.connected.desc"), true);
|
||||||
|
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.cantConnect.desc"));
|
player.sendMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".laser.cantConnect.desc"));
|
||||||
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,21 @@ import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.RegistryKey;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -36,102 +36,91 @@ import java.util.List;
|
||||||
public class ItemPhantomConnector extends ItemBase {
|
public class ItemPhantomConnector extends ItemBase {
|
||||||
|
|
||||||
public ItemPhantomConnector() {
|
public ItemPhantomConnector() {
|
||||||
super(name);
|
super(ActuallyItems.defaultNonStacking());
|
||||||
this.setMaxStackSize(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static World getStoredWorld(ItemStack stack) {
|
public static RegistryKey<World> getStoredWorld(ItemStack stack) {
|
||||||
CompoundNBT tag = stack.getTagCompound();
|
CompoundNBT tag = stack.getOrCreateTag();
|
||||||
if (tag != null) {
|
if (!tag.contains("WorldOfTileStored")) {
|
||||||
return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored"));
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation(tag.getString("WorldOfTileStored")));
|
||||||
|
}
|
||||||
|
|
||||||
public static BlockPos getStoredPosition(ItemStack stack) {
|
public static BlockPos getStoredPosition(ItemStack stack) {
|
||||||
CompoundNBT tag = stack.getTagCompound();
|
CompoundNBT tag = stack.getOrCreateTag();
|
||||||
if (tag != null) {
|
int x = tag.getInt("XCoordOfTileStored");
|
||||||
int x = tag.getInteger("XCoordOfTileStored");
|
int y = tag.getInt("YCoordOfTileStored");
|
||||||
int y = tag.getInteger("YCoordOfTileStored");
|
int z = tag.getInt("ZCoordOfTileStored");
|
||||||
int z = tag.getInteger("ZCoordOfTileStored");
|
|
||||||
if (!(x == 0 && y == 0 && z == 0)) {
|
if (!(x == 0 && y == 0 && z == 0)) {
|
||||||
return new BlockPos(x, y, z);
|
return new BlockPos(x, y, z);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearStorage(ItemStack stack, String... keys) {
|
public static void clearStorage(ItemStack stack, String... keys) {
|
||||||
if (stack.hasTagCompound()) {
|
CompoundNBT compound = stack.getOrCreateTag();
|
||||||
CompoundNBT compound = stack.getTagCompound();
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
compound.removeTag(key);
|
compound.remove(key);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeConnection(ItemStack stack, int x, int y, int z, World world) {
|
public static void storeConnection(ItemStack stack, int x, int y, int z, World world) {
|
||||||
CompoundNBT tag = stack.getTagCompound();
|
CompoundNBT tag = stack.getOrCreateTag();
|
||||||
if (tag == null) {
|
|
||||||
tag = new CompoundNBT();
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.setInteger("XCoordOfTileStored", x);
|
tag.putInt("XCoordOfTileStored", x);
|
||||||
tag.setInteger("YCoordOfTileStored", y);
|
tag.putInt("YCoordOfTileStored", y);
|
||||||
tag.setInteger("ZCoordOfTileStored", z);
|
tag.putInt("ZCoordOfTileStored", z);
|
||||||
tag.setInteger("WorldOfTileStored", world.provider.getDimension());
|
tag.putString("WorldOfTileStored", world.getDimensionKey().getLocation().toString());
|
||||||
|
|
||||||
stack.setTagCompound(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction par7, float par8, float par9, float par10) {
|
public ActionResultType onItemUse(ItemUseContext context) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = context.getPlayer().getHeldItem(context.getHand());
|
||||||
if (!world.isRemote) {
|
if (!context.getWorld().isRemote) {
|
||||||
//Passing Data to Phantoms
|
//Passing Data to Phantoms
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
BlockPos pos = context.getPos();
|
||||||
|
TileEntity tile = context.getWorld().getTileEntity(pos);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
//Passing to Phantom
|
//Passing to Phantom
|
||||||
if (tile instanceof IPhantomTile) {
|
if (tile instanceof IPhantomTile) {
|
||||||
BlockPos stored = getStoredPosition(stack);
|
BlockPos stored = getStoredPosition(stack);
|
||||||
if (stored != null && getStoredWorld(stack) == world) {
|
if (stored != null && getStoredWorld(stack) == context.getWorld().getDimensionKey()) {
|
||||||
((IPhantomTile) tile).setBoundPosition(stored);
|
((IPhantomTile) tile).setBoundPosition(stored);
|
||||||
if (tile instanceof TileEntityBase) {
|
if (tile instanceof TileEntityBase) {
|
||||||
((TileEntityBase) tile).sendUpdate();
|
((TileEntityBase) tile).sendUpdate();
|
||||||
}
|
}
|
||||||
clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
||||||
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.connected.desc"), true);
|
context.getPlayer().sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".phantom.connected.desc"), true);
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return EnumActionResult.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Storing Connections
|
//Storing Connections
|
||||||
storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
|
storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), context.getWorld());
|
||||||
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.stored.desc"), true);
|
context.getPlayer().sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".phantom.stored.desc"), true);
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CompoundNBT getShareTag(ItemStack stack) {
|
||||||
|
return new CompoundNBT();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getShareTag() {
|
public void addInformation(ItemStack stack, @Nullable World playerIn, List<ITextComponent> list, ITooltipFlag advanced) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> list, ITooltipFlag advanced) {
|
|
||||||
BlockPos coords = getStoredPosition(stack);
|
BlockPos coords = getStoredPosition(stack);
|
||||||
if (coords != null) {
|
if (coords != null) {
|
||||||
list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc") + ":");
|
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc").appendString(":"));
|
||||||
list.add("X: " + coords.getX());
|
list.add(new StringTextComponent("X: " + coords.getX()));
|
||||||
list.add("Y: " + coords.getY());
|
list.add(new StringTextComponent("Y: " + coords.getY()));
|
||||||
list.add("Z: " + coords.getZ());
|
list.add(new StringTextComponent("Z: " + coords.getZ()));
|
||||||
list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc"));
|
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc").mergeStyle(TextFormatting.ITALIC));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.EPIC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,19 +14,18 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.EnumActionResult;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -39,39 +38,42 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
super(ActuallyItems.defaultProps().maxStackSize(1));
|
super(ActuallyItems.defaultProps().maxStackSize(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: [port] might be the wrong event
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (stack.hasTagCompound()) {
|
CompoundNBT compound = stack.getOrCreateTag();
|
||||||
CompoundNBT compound = stack.getTagCompound();
|
if (compound.contains("UUIDMost")) {
|
||||||
if (compound.hasKey("UUIDMost")) {
|
|
||||||
UUID id = compound.getUniqueId("UUID");
|
UUID id = compound.getUniqueId("UUID");
|
||||||
PlayerEntity player = world.getPlayerEntityByUUID(id);
|
PlayerEntity player = world.getPlayerByUuid(id);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
||||||
entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.1"));
|
((PlayerEntity) entity).sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.1"), false);
|
||||||
player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.notice"));
|
player.sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.notice"), false);
|
||||||
//TheAchievements.GET_UNPROBED.get(player);
|
//TheAchievements.GET_UNPROBED.get(player);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
||||||
entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.2"));
|
((PlayerEntity) entity).sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.2"), false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
public ActionResultType onItemUse(ItemUseContext context) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
PlayerEntity player = context.getPlayer();
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
if (player == null) {
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack stack = player.getHeldItem(context.getHand());
|
||||||
|
TileEntity tile = context.getWorld().getTileEntity(context.getPos());
|
||||||
if (tile instanceof TileEntityPlayerInterface) {
|
if (tile instanceof TileEntityPlayerInterface) {
|
||||||
if (stack.hasTagCompound()) {
|
CompoundNBT compound = stack.getOrCreateTag();
|
||||||
CompoundNBT compound = stack.getTagCompound();
|
if (compound.contains("UUIDMost")) {
|
||||||
if (compound.hasKey("UUIDMost")) {
|
if (!context.getWorld().isRemote) {
|
||||||
if (!world.isRemote) {
|
|
||||||
TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile;
|
TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile;
|
||||||
face.connectedPlayer = compound.getUniqueId("UUID");
|
face.connectedPlayer = compound.getUniqueId("UUID");
|
||||||
face.playerName = compound.getString("Name");
|
face.playerName = compound.getString("Name");
|
||||||
|
@ -80,15 +82,14 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
|
|
||||||
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return ActionResultType.FAIL;
|
||||||
return EnumActionResult.FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase entity, Hand hand) {
|
public ActionResultType itemInteractionForEntity(ItemStack aStack, PlayerEntity player, LivingEntity entity, Hand hand) {
|
||||||
if (!player.world.isRemote) {
|
if (!player.world.isRemote) {
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
if (StackUtil.isValid(stack) && stack.getItem() == this) {
|
if (StackUtil.isValid(stack) && stack.getItem() == this) {
|
||||||
|
@ -96,28 +97,22 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
PlayerEntity playerHit = (PlayerEntity) entity;
|
PlayerEntity playerHit = (PlayerEntity) entity;
|
||||||
|
|
||||||
if (!playerHit.isSneaking()) {
|
if (!playerHit.isSneaking()) {
|
||||||
if (!stack.hasTagCompound()) {
|
CompoundNBT compound = stack.getOrCreateTag();
|
||||||
stack.setTagCompound(new CompoundNBT());
|
compound.putString("Name", playerHit.getName().getString());
|
||||||
}
|
compound.putUniqueId("UUID", playerHit.getUniqueID());
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
CompoundNBT compound = stack.getTagCompound();
|
|
||||||
compound.setString("Name", playerHit.getName());
|
|
||||||
compound.setUniqueId("UUID", playerHit.getUniqueID());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
public void addInformation(ItemStack stack, @Nullable World playerIn, List<ITextComponent> tooltip, ITooltipFlag advanced) {
|
||||||
if (stack.hasTagCompound()) {
|
if (stack.getOrCreateTag().contains("Name")) {
|
||||||
String name = stack.getTagCompound().getString("Name");
|
String name = stack.getOrCreateTag().getString("Name");
|
||||||
if (name != null) {
|
tooltip.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.probing").appendString(": " + name));
|
||||||
tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".playerProbe.probing") + ": " + name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,16 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.world.Explosion;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ItemResonantRice extends ItemBase {
|
public class ItemResonantRice extends ItemBase {
|
||||||
|
|
||||||
public ItemResonantRice() {
|
public ItemResonantRice() {
|
||||||
super(name);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,13 +29,8 @@ public class ItemResonantRice extends ItemBase {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true);
|
world.createExplosion(null, player.getPosX(), player.getPosY(), player.getPosZ(), 0.5F, Explosion.Mode.DESTROY);
|
||||||
}
|
}
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
return ActionResult.resultSuccess(stack);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.EPIC;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,39 +13,39 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.entity.EntityCreature;
|
import net.minecraft.entity.CreatureEntity;
|
||||||
import net.minecraft.entity.item.EntityXPOrb;
|
import net.minecraft.entity.item.ExperienceOrbEntity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.world.GameRules;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class ItemSolidifiedExperience extends ItemBase {
|
public class ItemSolidifiedExperience extends ItemBase {
|
||||||
|
|
||||||
public static final int SOLID_XP_AMOUNT = 8;
|
public static final int SOLID_XP_AMOUNT = 8;
|
||||||
|
|
||||||
public ItemSolidifiedExperience() {
|
public ItemSolidifiedExperience() {
|
||||||
super(name);
|
super();
|
||||||
|
|
||||||
|
// TODO: [port] move this to another place
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityDropEvent(LivingDropsEvent event) {
|
public void onEntityDropEvent(LivingDropsEvent event) {
|
||||||
if (ConfigBoolValues.DO_XP_DROPS.isEnabled()) {
|
if (ConfigBoolValues.DO_XP_DROPS.isEnabled()) {
|
||||||
if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof PlayerEntity && event.getEntityLiving().world.getGameRules().getBoolean("doMobLoot")) {
|
if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof PlayerEntity && event.getEntityLiving().world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||||
//Drop Solidified XP
|
//Drop Solidified XP
|
||||||
if (event.getEntityLiving() instanceof EntityCreature) {
|
if (event.getEntityLiving() instanceof CreatureEntity) {
|
||||||
if (event.getEntityLiving().world.rand.nextInt(10) <= event.getLootingLevel() * 2) {
|
if (event.getEntityLiving().world.rand.nextInt(10) <= event.getLootingLevel() * 2) {
|
||||||
event.getDrops().add(new ItemEntity(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(ActuallyItems.SOLIDIFIED_EXPERIENCE, event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1)));
|
event.getDrops().add(new ItemEntity(event.getEntityLiving().world, event.getEntityLiving().getPosX(), event.getEntityLiving().getPosY(), event.getEntityLiving().getPosZ(), new ItemStack(ActuallyItems.SOLIDIFIED_EXPERIENCE.get(), event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,18 +70,13 @@ public class ItemSolidifiedExperience extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigBoolValues.SOLID_XP_ALWAYS_ORBS.currentValue || player instanceof FakePlayer) {
|
if (ConfigBoolValues.SOLID_XP_ALWAYS_ORBS.currentValue || player instanceof FakePlayer) {
|
||||||
EntityXPOrb orb = new EntityXPOrb(world, player.posX + 0.5, player.posY + 0.5, player.posZ + 0.5, amount);
|
ExperienceOrbEntity orb = new ExperienceOrbEntity(world, player.getPosX() + 0.5, player.getPosY() + 0.5, player.getPosZ() + 0.5, amount);
|
||||||
orb.getEntityData().putBoolean(ActuallyAdditions.MODID + "FromSolidified", true);
|
orb.getPersistentData().putBoolean(ActuallyAdditions.MODID + "FromSolidified", true);
|
||||||
world.addEntity(orb);
|
world.addEntity(orb);
|
||||||
} else {
|
} else {
|
||||||
player.addExperience(amount);
|
player.addExperienceLevel(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
return ActionResult.resultSuccess(stack);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.UNCOMMON;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,141 +1,142 @@
|
||||||
/*
|
// TODO: [port] REMOVE THIS CLASS, NO longer needed
|
||||||
* This file ("ItemSpawnerChanger.java") is part of the Actually Additions mod for Minecraft.
|
///*
|
||||||
* It is created and owned by Ellpeck and distributed
|
// * This file ("ItemSpawnerChanger.java") is part of the Actually Additions mod for Minecraft.
|
||||||
* under the Actually Additions License to be found at
|
// * It is created and owned by Ellpeck and distributed
|
||||||
* http://ellpeck.de/actaddlicense
|
// * under the Actually Additions License to be found at
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
// * http://ellpeck.de/actaddlicense
|
||||||
*
|
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
* © 2015-2017 Ellpeck
|
// *
|
||||||
*/
|
// * © 2015-2017 Ellpeck
|
||||||
|
// */
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
//
|
||||||
|
//package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
//
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.BlockState;
|
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
//import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.EntityList;
|
//import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
//import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
//import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
//import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
//import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
//import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
//import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
//import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||||
import net.minecraft.util.EnumActionResult;
|
//import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
//import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.ResourceLocation;
|
//import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
//import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
//import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
//import net.minecraft.util.text.TextFormatting;
|
||||||
|
//import net.minecraft.world.World;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
public class ItemSpawnerChanger extends ItemBase {
|
//
|
||||||
|
//public class ItemSpawnerChanger extends ItemBase {
|
||||||
public ItemSpawnerChanger() {
|
//
|
||||||
super(name);
|
// public ItemSpawnerChanger() {
|
||||||
this.setMaxStackSize(1);
|
// super();
|
||||||
}
|
// this.setMaxStackSize(1);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
// @Override
|
||||||
if (!world.isRemote) {
|
// public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
// if (!world.isRemote) {
|
||||||
if (player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
// ItemStack stack = player.getHeldItemMainhand();
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
// if (player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||||
if (tile instanceof TileEntityMobSpawner) {
|
// TileEntity tile = world.getTileEntity(pos);
|
||||||
String entity = this.getStoredEntity(stack);
|
// if (tile instanceof TileEntityMobSpawner) {
|
||||||
if (entity != null) {
|
// String entity = this.getStoredEntity(stack);
|
||||||
MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) tile).getSpawnerBaseLogic();
|
// if (entity != null) {
|
||||||
|
// MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) tile).getSpawnerBaseLogic();
|
||||||
//This is a hacky way to remove the spawn potentials that make the spawner reset from time to time
|
//
|
||||||
//Don't judge, there isn't a method for it and it's better than Reflection hackiness
|
// //This is a hacky way to remove the spawn potentials that make the spawner reset from time to time
|
||||||
CompoundNBT compound = new CompoundNBT();
|
// //Don't judge, there isn't a method for it and it's better than Reflection hackiness
|
||||||
logic.writeToNBT(compound);
|
// CompoundNBT compound = new CompoundNBT();
|
||||||
compound.removeTag("SpawnPotentials");
|
// logic.writeToNBT(compound);
|
||||||
compound.removeTag("SpawnData");
|
// compound.removeTag("SpawnPotentials");
|
||||||
logic.readFromNBT(compound);
|
// compound.removeTag("SpawnData");
|
||||||
|
// logic.readFromNBT(compound);
|
||||||
logic.setEntityId(new ResourceLocation(entity));
|
//
|
||||||
|
// logic.setEntityId(new ResourceLocation(entity));
|
||||||
tile.markDirty();
|
//
|
||||||
|
// tile.markDirty();
|
||||||
BlockState state = world.getBlockState(pos);
|
//
|
||||||
world.notifyBlockUpdate(pos, state, state, 3);
|
// BlockState state = world.getBlockState(pos);
|
||||||
|
// world.notifyBlockUpdate(pos, state, state, 3);
|
||||||
ItemPhantomConnector.clearStorage(stack, "Entity");
|
//
|
||||||
|
// ItemPhantomConnector.clearStorage(stack, "Entity");
|
||||||
if (!player.isCreative()) {
|
//
|
||||||
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
// if (!player.isCreative()) {
|
||||||
}
|
// player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
||||||
|
// }
|
||||||
return EnumActionResult.SUCCESS;
|
//
|
||||||
}
|
// return EnumActionResult.SUCCESS;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return EnumActionResult.FAIL;
|
// }
|
||||||
}
|
// return EnumActionResult.FAIL;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase entity, Hand hand) {
|
// @Override
|
||||||
if (!player.world.isRemote) {
|
// public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase entity, Hand hand) {
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
// if (!player.world.isRemote) {
|
||||||
if (this.getStoredEntity(stack) == null) {
|
// ItemStack stack = player.getHeldItemMainhand();
|
||||||
if (this.storeClickedEntity(stack, entity)) {
|
// if (this.getStoredEntity(stack) == null) {
|
||||||
entity.setDead();
|
// if (this.storeClickedEntity(stack, entity)) {
|
||||||
}
|
// entity.setDead();
|
||||||
}
|
// }
|
||||||
return true;
|
// }
|
||||||
}
|
// return true;
|
||||||
return false;
|
// }
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) {
|
//
|
||||||
if (!stack.hasTagCompound()) {
|
// private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) {
|
||||||
stack.setTagCompound(new CompoundNBT());
|
// if (!stack.hasTagCompound()) {
|
||||||
}
|
// stack.setTagCompound(new CompoundNBT());
|
||||||
|
// }
|
||||||
if (!(entity instanceof PlayerEntity) && entity.isNonBoss()) {
|
//
|
||||||
ResourceLocation entityLoc = EntityList.getKey(entity.getClass());
|
// if (!(entity instanceof PlayerEntity) && entity.isNonBoss()) {
|
||||||
if (entityLoc != null) {
|
// ResourceLocation entityLoc = EntityList.getKey(entity.getClass());
|
||||||
String entityName = entityLoc.toString();
|
// if (entityLoc != null) {
|
||||||
if (entityName != null && !entityName.isEmpty()) {
|
// String entityName = entityLoc.toString();
|
||||||
for (String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()) {
|
// if (entityName != null && !entityName.isEmpty()) {
|
||||||
if (entityName.equals(name)) {
|
// for (String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()) {
|
||||||
return false;
|
// if (entityName.equals(name)) {
|
||||||
}
|
// return false;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
stack.getTagCompound().setString("Entity", entityName);
|
//
|
||||||
return true;
|
// stack.getTagCompound().setString("Entity", entityName);
|
||||||
}
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// }
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
private String getStoredEntity(ItemStack stack) {
|
//
|
||||||
if (stack.hasTagCompound()) {
|
// private String getStoredEntity(ItemStack stack) {
|
||||||
String entity = stack.getTagCompound().getString("Entity");
|
// if (stack.hasTagCompound()) {
|
||||||
if (entity != null && !entity.isEmpty()) {
|
// String entity = stack.getTagCompound().getString("Entity");
|
||||||
return entity;
|
// if (entity != null && !entity.isEmpty()) {
|
||||||
}
|
// return entity;
|
||||||
}
|
// }
|
||||||
return null;
|
// }
|
||||||
}
|
// return null;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
// @Override
|
||||||
String entity = this.getStoredEntity(stack);
|
// public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
||||||
if (entity != null) {
|
// String entity = this.getStoredEntity(stack);
|
||||||
list.add("Entity: " + entity);
|
// if (entity != null) {
|
||||||
list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc"));
|
// list.add("Entity: " + entity);
|
||||||
}
|
// list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc"));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -10,27 +10,27 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.passive.EntityBat;
|
import net.minecraft.entity.passive.BatEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemSword;
|
import net.minecraft.item.SwordItem;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class ItemWingsOfTheBats extends ItemBase {
|
public class ItemWingsOfTheBats extends ItemBase {
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
public static final int MAX_FLY_TIME = 800;
|
public static final int MAX_FLY_TIME = 800;
|
||||||
|
|
||||||
public ItemWingsOfTheBats() {
|
public ItemWingsOfTheBats() {
|
||||||
super(name);
|
super(ActuallyItems.defaultProps().maxStackSize(1));
|
||||||
this.setMaxStackSize(1);
|
|
||||||
|
|
||||||
|
// TODO: Lets move this somewhere global. Don't like event logic in a single place.
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,27 +67,23 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurabilityForDisplay(ItemStack stack) {
|
public double getDurabilityForDisplay(ItemStack stack) {
|
||||||
PlayerEntity player = ActuallyAdditions.PROXY.getCurrentPlayer();
|
PlayerEntity player = ClientProxy.getCurrentPlayer();
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
if (data != null) {
|
|
||||||
double diff = MAX_FLY_TIME - data.batWingsFlyTime;
|
double diff = MAX_FLY_TIME - data.batWingsFlyTime;
|
||||||
return 1 - diff / MAX_FLY_TIME;
|
return 1 - diff / MAX_FLY_TIME;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return super.getDurabilityForDisplay(stack);
|
return super.getDurabilityForDisplay(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
||||||
PlayerEntity player = ActuallyAdditions.PROXY.getCurrentPlayer();
|
PlayerEntity player = ClientProxy.getCurrentPlayer();
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
if (data != null) {
|
|
||||||
int curr = data.batWingsFlyTime;
|
int curr = data.batWingsFlyTime;
|
||||||
return MathHelper.hsvToRGB(Math.max(0.0F, 1 - (float) curr / MAX_FLY_TIME) / 3.0F, 1.0F, 1.0F);
|
return MathHelper.hsvToRGB(Math.max(0.0F, 1 - (float) curr / MAX_FLY_TIME) / 3.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return super.getRGBDurabilityForDisplay(stack);
|
return super.getRGBDurabilityForDisplay(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,19 +93,21 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
|
|
||||||
if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && source instanceof PlayerEntity) {
|
if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && source instanceof PlayerEntity) {
|
||||||
//Drop Wings from Bats
|
//Drop Wings from Bats
|
||||||
if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) {
|
if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof BatEntity) {
|
||||||
int looting = event.getLootingLevel();
|
int looting = event.getLootingLevel();
|
||||||
|
|
||||||
Iterable<ItemStack> equip = source.getHeldEquipment();
|
Iterable<ItemStack> equip = source.getHeldEquipment();
|
||||||
for (ItemStack stack : equip) {
|
for (ItemStack stack : equip) {
|
||||||
if (StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword) {
|
// Todo: [port] this might not work anymore due to the way things are checked
|
||||||
|
if (StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName().getString()) && stack.getItem() instanceof SwordItem) {
|
||||||
looting += 3;
|
looting += 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEntityLiving().world.rand.nextInt(15) <= looting * 2) {
|
if (event.getEntityLiving().world.rand.nextInt(15) <= looting * 2) {
|
||||||
event.getDrops().add(new ItemEntity(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(ActuallyItems.BAT_WING.get(), event.getEntityLiving().world.rand.nextInt(2 + looting) + 1)));
|
LivingEntity entityLiving = event.getEntityLiving();
|
||||||
|
event.getDrops().add(new ItemEntity(event.getEntityLiving().world, entityLiving.getPosX(), entityLiving.getPosY(), entityLiving.getPosZ(), new ItemStack(ActuallyItems.BAT_WING.get(), event.getEntityLiving().world.rand.nextInt(2 + looting) + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,12 +137,12 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME) {
|
if (wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME) {
|
||||||
player.capabilities.allowFlying = true;
|
player.abilities.allowFlying = true;
|
||||||
|
|
||||||
if (player.capabilities.isFlying) {
|
if (player.abilities.isFlying) {
|
||||||
data.batWingsFlyTime++;
|
data.batWingsFlyTime++;
|
||||||
|
|
||||||
if (player.world.getTotalWorldTime() % 10 == 0) {
|
if (player.world.getWorldInfo().getGameTime() % 10 == 0) {
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,21 +153,21 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
data.shouldDisableBatWings = true;
|
data.shouldDisableBatWings = true;
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
|
|
||||||
player.capabilities.allowFlying = false;
|
player.abilities.allowFlying = false;
|
||||||
player.capabilities.isFlying = false;
|
player.abilities.isFlying = false;
|
||||||
player.capabilities.disableDamage = false;
|
player.abilities.disableDamage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tryDeduct && data.batWingsFlyTime > 0) {
|
if (tryDeduct && data.batWingsFlyTime > 0) {
|
||||||
int deductTime = 0;
|
int deductTime = 0;
|
||||||
|
|
||||||
if (!player.capabilities.isFlying) {
|
if (!player.abilities.isFlying) {
|
||||||
deductTime = 2;
|
deductTime = 2;
|
||||||
} else {
|
} else {
|
||||||
BlockPos pos = new BlockPos(player.posX, player.posY + player.height, player.posZ);
|
BlockPos pos = new BlockPos(player.getPosX(), player.getPosY() + player.getHeight(), player.getPosZ());
|
||||||
BlockState state = player.world.getBlockState(pos);
|
BlockState state = player.world.getBlockState(pos);
|
||||||
if (state != null && state.isSideSolid(player.world, pos, Direction.DOWN)) {
|
if (state.isSolidSide(player.world, pos, Direction.DOWN)) {
|
||||||
deductTime = 10;
|
deductTime = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +175,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
if (deductTime > 0) {
|
if (deductTime > 0) {
|
||||||
data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime - deductTime);
|
data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime - deductTime);
|
||||||
|
|
||||||
if (player.world.getTotalWorldTime() % 10 == 0) {
|
if (player.world.getWorldInfo().getGameTime() % 10 == 0) {
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,21 +187,16 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (data.hasBatWings) {
|
if (data.hasBatWings) {
|
||||||
player.capabilities.allowFlying = true;
|
player.abilities.allowFlying = true;
|
||||||
} else if (data.shouldDisableBatWings) { //so that other modded flying won't be disabled
|
} else if (data.shouldDisableBatWings) { //so that other modded flying won't be disabled
|
||||||
data.shouldDisableBatWings = false;
|
data.shouldDisableBatWings = false;
|
||||||
|
|
||||||
player.capabilities.allowFlying = false;
|
player.abilities.allowFlying = false;
|
||||||
player.capabilities.isFlying = false;
|
player.abilities.isFlying = false;
|
||||||
player.capabilities.disableDamage = false;
|
player.abilities.disableDamage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.EPIC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class ClientProxy {
|
||||||
// COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING.add(block);
|
// COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING.add(block);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static ClientPlayerEntity getCurrentPlayer() {
|
public static ClientPlayerEntity getCurrentPlayer() {
|
||||||
return Minecraft.getInstance().player;
|
return Minecraft.getInstance().player;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable {
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public ITextComponent getDisplayName() {
|
// public ITextComponent getDisplayName() {
|
||||||
// return new TextComponentTranslation(this.getNameForTranslation());
|
// return new TranslationTextComponent(this.getNameForTranslation());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue