mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-24 16:18:33 +01:00
Compare commits
No commits in common. "420188975ee760e9838d193559c26fcc6cc970f5" and "2419a0e8608e8cafbd3e61e204bc8371ea89507d" have entirely different histories.
420188975e
...
2419a0e860
15 changed files with 451 additions and 407 deletions
|
@ -147,7 +147,7 @@ public final class ActuallyItems {
|
||||||
public static final RegistryObject<Item> POTION_RING = ITEMS.register("potion_ring", () -> new ItemPotionRing(false));
|
public static final RegistryObject<Item> POTION_RING = ITEMS.register("potion_ring", () -> new ItemPotionRing(false));
|
||||||
public static final RegistryObject<Item> POTION_RING_ADVANCED = ITEMS.register("potion_ring_advanced", () -> new ItemPotionRing(true));
|
public static final RegistryObject<Item> POTION_RING_ADVANCED = ITEMS.register("potion_ring_advanced", () -> new ItemPotionRing(true));
|
||||||
|
|
||||||
public static final RegistryObject<Item> HAIRY_BALL = ITEMS.register("hairy_ball", ItemHairBall::new);
|
public static final RegistryObject<Item> HAIRY_BALL = ITEMS.register("hairy_ball", ItemHairyBall::new);
|
||||||
public static final RegistryObject<Item> COFFEE_BEANS = ITEMS.register("coffee_beans", ItemCoffeeBean::new);
|
public static final RegistryObject<Item> COFFEE_BEANS = ITEMS.register("coffee_beans", ItemCoffeeBean::new);
|
||||||
|
|
||||||
public static final RegistryObject<Item> RICE_SEED = ITEMS.register("rice_seed", () -> new ItemSeed("seedRice", ActuallyBlocks.RICE.get(), FOOD.get(), TheFoods.RICE.ordinal()));
|
public static final RegistryObject<Item> RICE_SEED = ITEMS.register("rice_seed", () -> new ItemSeed("seedRice", ActuallyBlocks.RICE.get(), FOOD.get(), TheFoods.RICE.ordinal()));
|
||||||
|
@ -242,8 +242,4 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,15 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockGrass;
|
||||||
import net.minecraft.block.GrassBlock;
|
|
||||||
import net.minecraft.block.IGrowable;
|
import net.minecraft.block.IGrowable;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
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.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -31,11 +30,11 @@ import java.util.List;
|
||||||
public class ItemGrowthRing extends ItemEnergy {
|
public class ItemGrowthRing extends ItemEnergy {
|
||||||
|
|
||||||
public ItemGrowthRing() {
|
public ItemGrowthRing() {
|
||||||
super(1000000, 2000);
|
super(1000000, 2000, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||||
if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) {
|
if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,17 +47,17 @@ public class ItemGrowthRing extends ItemEnergy {
|
||||||
List<BlockPos> blocks = new ArrayList<>();
|
List<BlockPos> blocks = new ArrayList<>();
|
||||||
|
|
||||||
//Adding all possible Blocks
|
//Adding all possible Blocks
|
||||||
if (player.world.getGameTime() % 30 == 0) {
|
if (player.world.getTotalWorldTime() % 30 == 0) {
|
||||||
int range = 3;
|
int range = 3;
|
||||||
for (int x = -range; x < range + 1; x++) {
|
for (int x = -range; x < range + 1; x++) {
|
||||||
for (int z = -range; z < range + 1; z++) {
|
for (int z = -range; z < range + 1; z++) {
|
||||||
for (int y = -range; y < range + 1; y++) {
|
for (int y = -range; y < range + 1; y++) {
|
||||||
int theX = MathHelper.floor(player.getPosX() + x);
|
int theX = MathHelper.floor(player.posX + x);
|
||||||
int theY = MathHelper.floor(player.getPosY() + y);
|
int theY = MathHelper.floor(player.posY + y);
|
||||||
int theZ = MathHelper.floor(player.getPosZ() + z);
|
int theZ = MathHelper.floor(player.posZ + z);
|
||||||
BlockPos posInQuestion = new BlockPos(theX, theY, theZ);
|
BlockPos posInQuestion = new BlockPos(theX, theY, theZ);
|
||||||
Block theBlock = world.getBlockState(posInQuestion).getBlock();
|
Block theBlock = world.getBlockState(posInQuestion).getBlock();
|
||||||
if ((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof GrassBlock)) {
|
if ((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)) {
|
||||||
blocks.add(posInQuestion);
|
blocks.add(posInQuestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,11 +72,12 @@ public class ItemGrowthRing extends ItemEnergy {
|
||||||
|
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
block.tick(world.getBlockState(pos), (ServerWorld) world, pos, world.rand);
|
int metaBefore = block.getMetaFromState(state);
|
||||||
|
block.updateTick(world, pos, world.getBlockState(pos), world.rand);
|
||||||
|
|
||||||
//Show Particles if Metadata changed
|
//Show Particles if Metadata changed
|
||||||
BlockState newState = world.getBlockState(pos);
|
BlockState newState = world.getBlockState(pos);
|
||||||
if (newState != state) {
|
if (newState.getBlock().getMetaFromState(newState) != metaBefore) {
|
||||||
world.playEvent(2005, pos, 0);
|
world.playEvent(2005, pos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +92,9 @@ public class ItemGrowthRing extends ItemEnergy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return EnumRarity.EPIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,28 +15,24 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.passive.OcelotEntity;
|
import net.minecraft.entity.passive.EntityOcelot;
|
||||||
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.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ItemHairBall extends ItemBase {
|
public class ItemHairyBall extends ItemBase {
|
||||||
|
|
||||||
private final UUID KittyVanCatUUID = UUID.fromString("681d4e20-10ef-40c9-a0a5-ba2f1995ef44");
|
private final UUID KittyVanCatUUID = UUID.fromString("681d4e20-10ef-40c9-a0a5-ba2f1995ef44");
|
||||||
|
|
||||||
public ItemHairBall() {
|
public ItemHairyBall() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// TODO: [port] move this.
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,41 +40,30 @@ public class ItemHairBall extends ItemBase {
|
||||||
public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event) {
|
public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event) {
|
||||||
//Ocelots dropping Hair Balls
|
//Ocelots dropping Hair Balls
|
||||||
if (ConfigBoolValues.DO_CAT_DROPS.isEnabled() && event.getEntityLiving() != null && event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote) {
|
if (ConfigBoolValues.DO_CAT_DROPS.isEnabled() && event.getEntityLiving() != null && event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote) {
|
||||||
if (event.getEntityLiving() instanceof OcelotEntity && catIsTamedReflection((OcelotEntity) event.getEntityLiving()) || event.getEntityLiving() instanceof PlayerEntity && event.getEntityLiving().getUniqueID().equals(this.KittyVanCatUUID)) {
|
if (event.getEntityLiving() instanceof EntityOcelot && ((EntityOcelot) event.getEntityLiving()).isTamed() || event.getEntityLiving() instanceof PlayerEntity && event.getEntityLiving().getUniqueID().equals(this.KittyVanCatUUID)) {
|
||||||
if (event.getEntityLiving().world.rand.nextInt(ConfigIntValues.FUR_CHANCE.getValue()) == 0) {
|
if (event.getEntityLiving().world.rand.nextInt(ConfigIntValues.FUR_CHANCE.getValue()) == 0) {
|
||||||
ItemEntity item = new ItemEntity(event.getEntityLiving().world, event.getEntityLiving().getPosX() + 0.5, event.getEntityLiving().getPosY() + 0.5, event.getEntityLiving().getPosZ() + 0.5, new ItemStack(ActuallyItems.HAIRY_BALL.get()));
|
ItemEntity item = new ItemEntity(event.getEntityLiving().world, event.getEntityLiving().posX + 0.5, event.getEntityLiving().posY + 0.5, event.getEntityLiving().posZ + 0.5, new ItemStack(ActuallyItems.HAIRY_BALL));
|
||||||
event.getEntityLiving().world.addEntity(item);
|
event.getEntityLiving().world.addEntity(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean catIsTamedReflection(OcelotEntity entity) {
|
|
||||||
try {
|
|
||||||
Method isTrusting = OcelotEntity.class.getDeclaredMethod("isTrusting");
|
|
||||||
return (boolean) isTrusting.invoke(entity);
|
|
||||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
ItemStack returnItem = this.getRandomReturnItem(world.rand);
|
ItemStack returnItem = this.getRandomReturnItem(world.rand);
|
||||||
if (!player.inventory.addItemStackToInventory(returnItem)) {
|
if (!player.inventory.addItemStackToInventory(returnItem)) {
|
||||||
ItemEntity entityItem = new ItemEntity(player.world, player.getPosX(), player.getPosY(), player.getPosZ(), returnItem);
|
ItemEntity entityItem = new ItemEntity(player.world, player.posX, player.posY, player.posZ, returnItem);
|
||||||
entityItem.setPickupDelay(0);
|
entityItem.setPickupDelay(0);
|
||||||
player.world.addEntity(entityItem);
|
player.world.addEntity(entityItem);
|
||||||
}
|
}
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
|
|
||||||
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
|
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
}
|
}
|
||||||
return ActionResult.resultSuccess(stack);
|
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getRandomReturnItem(Random rand) {
|
public ItemStack getRandomReturnItem(Random rand) {
|
|
@ -12,31 +12,37 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.entity.ai.attributes.Attribute;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.entity.ai.attributes.Attributes;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ItemKnife extends ItemBase {
|
public class ItemKnife extends ItemBase {
|
||||||
|
|
||||||
public ItemKnife() {
|
public ItemKnife() {
|
||||||
super(ActuallyItems.defaultNonStacking().defaultMaxDamage(100).setNoRepair());
|
super(name);
|
||||||
|
this.setMaxDamage(100);
|
||||||
|
this.setMaxStackSize(1);
|
||||||
|
this.setContainerItem(this);
|
||||||
|
this.setNoRepair();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
// @Override
|
public boolean getShareTag() {
|
||||||
// public boolean getShareTag() {
|
return true;
|
||||||
// return true;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) {
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
Multimap<Attribute, AttributeModifier> map = super.getAttributeModifiers(slot, stack);
|
return EnumRarity.EPIC;
|
||||||
if (slot == EquipmentSlotType.MAINHAND) {
|
}
|
||||||
// TODO: [port] validate
|
|
||||||
map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier("Knife Modifier", 3, AttributeModifier.Operation.ADDITION));
|
@Override
|
||||||
|
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||||
|
Multimap<String, AttributeModifier> map = super.getAttributeModifiers(slot, stack);
|
||||||
|
if (slot == EntityEquipmentSlot.MAINHAND) {
|
||||||
|
map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Knife Modifier", 3, 0));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +50,7 @@ public class ItemKnife extends ItemBase {
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getContainerItem(ItemStack stack) {
|
public ItemStack getContainerItem(ItemStack stack) {
|
||||||
ItemStack theStack = stack.copy();
|
ItemStack theStack = stack.copy();
|
||||||
theStack.setDamage(theStack.getDamage() + 1);
|
theStack.setItemDamage(theStack.getItemDamage() + 1);
|
||||||
return theStack;
|
return theStack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,18 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
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.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||||
|
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.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.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.EnumActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
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 java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,23 +33,20 @@ import java.util.List;
|
||||||
public class ItemLaserWrench extends ItemBase {
|
public class ItemLaserWrench extends ItemBase {
|
||||||
|
|
||||||
public ItemLaserWrench() {
|
public ItemLaserWrench() {
|
||||||
super(ActuallyItems.defaultNonStacking());
|
super(name);
|
||||||
|
this.setMaxStackSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onItemUse(ItemUseContext context) {
|
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction par7, float par8, float par9, float par10) {
|
||||||
BlockPos pos = context.getPos();
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
World world = context.getWorld();
|
|
||||||
PlayerEntity player = context.getPlayer();
|
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItem(context.getHand());
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if (tile instanceof TileEntityLaserRelay) {
|
if (tile instanceof TileEntityLaserRelay) {
|
||||||
TileEntityLaserRelay relay = (TileEntityLaserRelay) tile;
|
TileEntityLaserRelay relay = (TileEntityLaserRelay) tile;
|
||||||
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 TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".laser.stored.desc"), true);
|
player.sendStatusMessage(new TextComponentTranslation("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) {
|
||||||
|
@ -59,44 +57,47 @@ 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.getDimensionKey() && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)) {
|
if (ItemPhantomConnector.getStoredWorld(stack) == world && 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 TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".laser.connected.desc"), true);
|
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.connected.desc"), true);
|
||||||
|
|
||||||
return ActionResultType.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".laser.cantConnect.desc"), false);
|
player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.cantConnect.desc"));
|
||||||
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ActionResultType.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return ActionResultType.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // TODO: [port] ensure this is correct
|
|
||||||
// @Nullable
|
|
||||||
// @Override
|
|
||||||
// public CompoundNBT getShareTag(ItemStack stack) {
|
|
||||||
// return new CompoundNBT();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, World playerIn, List<ITextComponent> list, ITooltipFlag advanced) {
|
public boolean getShareTag() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
||||||
BlockPos coords = ItemPhantomConnector.getStoredPosition(stack);
|
BlockPos coords = ItemPhantomConnector.getStoredPosition(stack);
|
||||||
if (coords != null) {
|
if (coords != null) {
|
||||||
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc").appendString(":"));
|
list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc") + ":");
|
||||||
list.add(new StringTextComponent("X: " + coords.getX()));
|
list.add("X: " + coords.getX());
|
||||||
list.add(new StringTextComponent("Y: " + coords.getY()));
|
list.add("Y: " + coords.getY());
|
||||||
list.add(new StringTextComponent("Z: " + coords.getZ()));
|
list.add("Z: " + coords.getZ());
|
||||||
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc").mergeStyle(TextFormatting.ITALIC));
|
list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return EnumRarity.EPIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,20 +12,25 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
|
import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.block.BlockBush;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
|
import net.minecraft.item.EnumAction;
|
||||||
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.UseAction;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
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.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
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.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IForgeShearable;
|
import net.minecraftforge.common.IShearable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -42,27 +47,35 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem {
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||||
player.setActiveHand(hand);
|
player.setActiveHand(hand);
|
||||||
return ActionResult.resultSuccess(player.getHeldItem(hand));
|
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UseAction getUseAction(ItemStack stack) {
|
public EnumAction getItemUseAction(ItemStack stack) {
|
||||||
return UseAction.BOW;
|
return EnumAction.BOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUseDuration(ItemStack stack) {
|
public int getMaxItemUseDuration(ItemStack stack) {
|
||||||
|
//Cuz you won't hold it for that long right-clicking anyways
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUsingTick(ItemStack stack, LivingEntity player, int count) {
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
this.doUpdate(player.world, MathHelper.floor(player.getPosX()), MathHelper.floor(player.getPosY()), MathHelper.floor(player.getPosZ()), count, stack);
|
return this.isAdvanced
|
||||||
|
? EnumRarity.EPIC
|
||||||
|
: EnumRarity.RARE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUsingTick(ItemStack stack, EntityLivingBase player, int time) {
|
||||||
|
this.doUpdate(player.world, MathHelper.floor(player.posX), MathHelper.floor(player.posY), MathHelper.floor(player.posZ), time, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doUpdate(World world, int x, int y, int z, int time, ItemStack stack) {
|
private boolean doUpdate(World world, int x, int y, int z, int time, ItemStack stack) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (time <= this.getUseDuration(stack) && (this.isAdvanced || time % 3 == 0)) {
|
if (time <= this.getMaxItemUseDuration(stack) && (this.isAdvanced || time % 3 == 0)) {
|
||||||
//Breaks the Blocks
|
//Breaks the Blocks
|
||||||
boolean broke = this.breakStuff(world, x, y, z);
|
boolean broke = this.breakStuff(world, x, y, z);
|
||||||
//Plays a Minecart sounds (It really sounds like a Leaf Blower!)
|
//Plays a Minecart sounds (It really sounds like a Leaf Blower!)
|
||||||
|
@ -97,7 +110,7 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem {
|
||||||
BlockPos pos = new BlockPos(x + reachX, y + reachY, z + reachZ);
|
BlockPos pos = new BlockPos(x + reachX, y + reachY, z + reachZ);
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
Block block = world.getBlockState(pos).getBlock();
|
||||||
|
|
||||||
if ((block instanceof BushBlock || block instanceof IForgeShearable) && (this.isAdvanced || block instanceof LeavesBlock)) {
|
if (block != null && (block instanceof BlockBush || block instanceof IShearable) && (this.isAdvanced || !block.isLeaves(world.getBlockState(pos), world, pos))) {
|
||||||
breakPositions.add(pos);
|
breakPositions.add(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,8 +123,7 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem {
|
||||||
BlockPos theCoord = breakPositions.get(0);
|
BlockPos theCoord = breakPositions.get(0);
|
||||||
BlockState theState = world.getBlockState(theCoord);
|
BlockState theState = world.getBlockState(theCoord);
|
||||||
|
|
||||||
world.destroyBlock(theCoord, true);
|
theState.getBlock().dropBlockAsItem(world, theCoord, theState, 0);
|
||||||
// theState.getBlock().dropBlockAsItem(world, theCoord, theState, 0);
|
|
||||||
//Plays the Breaking Sound
|
//Plays the Breaking Sound
|
||||||
world.playEvent(2001, theCoord, Block.getStateId(theState));
|
world.playEvent(2001, theCoord, Block.getStateId(theState));
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,10 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
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.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -26,7 +28,7 @@ import java.util.List;
|
||||||
public class ItemMagnetRing extends ItemEnergy {
|
public class ItemMagnetRing extends ItemEnergy {
|
||||||
|
|
||||||
public ItemMagnetRing() {
|
public ItemMagnetRing() {
|
||||||
super(200000, 1000);
|
super(200000, 1000, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +37,7 @@ public class ItemMagnetRing extends ItemEnergy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||||
if (entity instanceof PlayerEntity && !world.isRemote && !ItemUtil.isEnabled(stack)) {
|
if (entity instanceof PlayerEntity && !world.isRemote && !ItemUtil.isEnabled(stack)) {
|
||||||
PlayerEntity player = (PlayerEntity) entity;
|
PlayerEntity player = (PlayerEntity) entity;
|
||||||
if (player.isCreative() || player.isSpectator()) {
|
if (player.isCreative() || player.isSpectator()) {
|
||||||
|
@ -44,14 +46,13 @@ public class ItemMagnetRing extends ItemEnergy {
|
||||||
if (!entity.isSneaking()) {
|
if (!entity.isSneaking()) {
|
||||||
//Get all the Items in the area
|
//Get all the Items in the area
|
||||||
int range = 5;
|
int range = 5;
|
||||||
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(entity.getPosX() - range, entity.getPosY() - range, entity.getPosZ() - range, entity.getPosX() + range, entity.getPosY() + range, entity.getPosZ() + range));
|
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range));
|
||||||
if (!items.isEmpty()) {
|
if (!items.isEmpty()) {
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
// TODO: [port] check this data is being saved on the time
|
if (item.getEntityData().getBoolean("PreventRemoteMovement")) {
|
||||||
if (item.getPersistentData().getBoolean("PreventRemoteMovement")) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (item.isAlive() && !item.cannotPickup()) {
|
if (!item.isDead && !item.cannotPickup()) {
|
||||||
int energyForItem = 50 * item.getItem().getCount();
|
int energyForItem = 50 * item.getItem().getCount();
|
||||||
|
|
||||||
if (this.getEnergyStored(stack) >= energyForItem) {
|
if (this.getEnergyStored(stack) >= energyForItem) {
|
||||||
|
@ -60,7 +61,7 @@ public class ItemMagnetRing extends ItemEnergy {
|
||||||
item.onCollideWithPlayer(player);
|
item.onCollideWithPlayer(player);
|
||||||
|
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
if (!item.isAlive() || !ItemStack.areItemStacksEqual(item.getItem(), oldItem)) {
|
if (item.isDead || !ItemStack.areItemStacksEqual(item.getItem(), oldItem)) {
|
||||||
this.extractEnergyInternal(stack, energyForItem, false);
|
this.extractEnergyInternal(stack, energyForItem, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,9 +77,13 @@ public class ItemMagnetRing extends ItemEnergy {
|
||||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand hand) {
|
||||||
if (!worldIn.isRemote && player.isSneaking()) {
|
if (!worldIn.isRemote && player.isSneaking()) {
|
||||||
ItemUtil.changeEnabled(player, hand);
|
ItemUtil.changeEnabled(player, hand);
|
||||||
return ActionResult.resultSuccess(player.getHeldItem(hand));
|
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onItemRightClick(worldIn, player, hand);
|
return super.onItemRightClick(worldIn, player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return EnumRarity.EPIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ActionResultType;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.RegistryKey;
|
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.math.BlockPos;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
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,91 +36,102 @@ import java.util.List;
|
||||||
public class ItemPhantomConnector extends ItemBase {
|
public class ItemPhantomConnector extends ItemBase {
|
||||||
|
|
||||||
public ItemPhantomConnector() {
|
public ItemPhantomConnector() {
|
||||||
super(ActuallyItems.defaultNonStacking());
|
super(name);
|
||||||
|
this.setMaxStackSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegistryKey<World> getStoredWorld(ItemStack stack) {
|
public static World getStoredWorld(ItemStack stack) {
|
||||||
CompoundNBT tag = stack.getOrCreateTag();
|
CompoundNBT tag = stack.getTagCompound();
|
||||||
if (!tag.contains("WorldOfTileStored")) {
|
if (tag != null) {
|
||||||
|
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.getOrCreateTag();
|
CompoundNBT tag = stack.getTagCompound();
|
||||||
int x = tag.getInt("XCoordOfTileStored");
|
if (tag != null) {
|
||||||
int y = tag.getInt("YCoordOfTileStored");
|
int x = tag.getInteger("XCoordOfTileStored");
|
||||||
int z = tag.getInt("ZCoordOfTileStored");
|
int y = tag.getInteger("YCoordOfTileStored");
|
||||||
|
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) {
|
||||||
CompoundNBT compound = stack.getOrCreateTag();
|
if (stack.hasTagCompound()) {
|
||||||
|
CompoundNBT compound = stack.getTagCompound();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
compound.remove(key);
|
compound.removeTag(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.getOrCreateTag();
|
CompoundNBT tag = stack.getTagCompound();
|
||||||
|
if (tag == null) {
|
||||||
|
tag = new CompoundNBT();
|
||||||
|
}
|
||||||
|
|
||||||
tag.putInt("XCoordOfTileStored", x);
|
tag.setInteger("XCoordOfTileStored", x);
|
||||||
tag.putInt("YCoordOfTileStored", y);
|
tag.setInteger("YCoordOfTileStored", y);
|
||||||
tag.putInt("ZCoordOfTileStored", z);
|
tag.setInteger("ZCoordOfTileStored", z);
|
||||||
tag.putString("WorldOfTileStored", world.getDimensionKey().getLocation().toString());
|
tag.setInteger("WorldOfTileStored", world.provider.getDimension());
|
||||||
|
|
||||||
|
stack.setTagCompound(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onItemUse(ItemUseContext context) {
|
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction par7, float par8, float par9, float par10) {
|
||||||
ItemStack stack = context.getPlayer().getHeldItem(context.getHand());
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if (!context.getWorld().isRemote) {
|
if (!world.isRemote) {
|
||||||
//Passing Data to Phantoms
|
//Passing Data to Phantoms
|
||||||
BlockPos pos = context.getPos();
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
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) == context.getWorld().getDimensionKey()) {
|
if (stored != null && getStoredWorld(stack) == world) {
|
||||||
((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");
|
||||||
context.getPlayer().sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".phantom.connected.desc"), true);
|
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.connected.desc"), true);
|
||||||
return ActionResultType.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return ActionResultType.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Storing Connections
|
//Storing Connections
|
||||||
storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), context.getWorld());
|
storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
|
||||||
context.getPlayer().sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".phantom.stored.desc"), true);
|
player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.stored.desc"), true);
|
||||||
}
|
}
|
||||||
return ActionResultType.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public CompoundNBT getShareTag(ItemStack stack) {
|
|
||||||
return new CompoundNBT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<ITextComponent> list, ITooltipFlag advanced) {
|
public boolean getShareTag() {
|
||||||
|
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(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc").appendString(":"));
|
list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc") + ":");
|
||||||
list.add(new StringTextComponent("X: " + coords.getX()));
|
list.add("X: " + coords.getX());
|
||||||
list.add(new StringTextComponent("Y: " + coords.getY()));
|
list.add("Y: " + coords.getY());
|
||||||
list.add(new StringTextComponent("Z: " + coords.getZ()));
|
list.add("Z: " + coords.getZ());
|
||||||
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc").mergeStyle(TextFormatting.ITALIC));
|
list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return EnumRarity.EPIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,19 @@ 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.LivingEntity;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
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.ActionResultType;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -38,42 +39,39 @@ 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 inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
CompoundNBT compound = stack.getOrCreateTag();
|
if (stack.hasTagCompound()) {
|
||||||
if (compound.contains("UUIDMost")) {
|
CompoundNBT compound = stack.getTagCompound();
|
||||||
|
if (compound.hasKey("UUIDMost")) {
|
||||||
UUID id = compound.getUniqueId("UUID");
|
UUID id = compound.getUniqueId("UUID");
|
||||||
PlayerEntity player = world.getPlayerByUuid(id);
|
PlayerEntity player = world.getPlayerEntityByUUID(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");
|
||||||
((PlayerEntity) entity).sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.1"), false);
|
entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.1"));
|
||||||
player.sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.notice"), false);
|
player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.notice"));
|
||||||
//TheAchievements.GET_UNPROBED.get(player);
|
//TheAchievements.GET_UNPROBED.get(player);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
||||||
((PlayerEntity) entity).sendStatusMessage(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.2"), false);
|
entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.2"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onItemUse(ItemUseContext context) {
|
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||||
PlayerEntity player = context.getPlayer();
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if (player == null) {
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
return ActionResultType.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItem(context.getHand());
|
|
||||||
TileEntity tile = context.getWorld().getTileEntity(context.getPos());
|
|
||||||
if (tile instanceof TileEntityPlayerInterface) {
|
if (tile instanceof TileEntityPlayerInterface) {
|
||||||
CompoundNBT compound = stack.getOrCreateTag();
|
if (stack.hasTagCompound()) {
|
||||||
if (compound.contains("UUIDMost")) {
|
CompoundNBT compound = stack.getTagCompound();
|
||||||
if (!context.getWorld().isRemote) {
|
if (compound.hasKey("UUIDMost")) {
|
||||||
|
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");
|
||||||
|
@ -82,14 +80,15 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
|
|
||||||
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name");
|
||||||
}
|
}
|
||||||
return ActionResultType.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ActionResultType.FAIL;
|
}
|
||||||
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType itemInteractionForEntity(ItemStack aStack, PlayerEntity player, LivingEntity entity, Hand hand) {
|
public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase 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) {
|
||||||
|
@ -97,22 +96,28 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
PlayerEntity playerHit = (PlayerEntity) entity;
|
PlayerEntity playerHit = (PlayerEntity) entity;
|
||||||
|
|
||||||
if (!playerHit.isSneaking()) {
|
if (!playerHit.isSneaking()) {
|
||||||
CompoundNBT compound = stack.getOrCreateTag();
|
if (!stack.hasTagCompound()) {
|
||||||
compound.putString("Name", playerHit.getName().getString());
|
stack.setTagCompound(new CompoundNBT());
|
||||||
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 ActionResultType.FAIL;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<ITextComponent> tooltip, ITooltipFlag advanced) {
|
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
||||||
if (stack.getOrCreateTag().contains("Name")) {
|
if (stack.hasTagCompound()) {
|
||||||
String name = stack.getOrCreateTag().getString("Name");
|
String name = stack.getTagCompound().getString("Name");
|
||||||
tooltip.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".playerProbe.probing").appendString(": " + name));
|
if (name != null) {
|
||||||
|
tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".playerProbe.probing") + ": " + name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,17 @@ 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();
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,8 +30,13 @@ 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.getPosX(), player.getPosY(), player.getPosZ(), 0.5F, Explosion.Mode.DESTROY);
|
world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true);
|
||||||
}
|
}
|
||||||
return ActionResult.resultSuccess(stack);
|
return new ActionResult<>(EnumActionResult.SUCCESS, 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.CreatureEntity;
|
import net.minecraft.entity.EntityCreature;
|
||||||
import net.minecraft.entity.item.ExperienceOrbEntity;
|
import net.minecraft.entity.item.EntityXPOrb;
|
||||||
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.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.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();
|
super(name);
|
||||||
|
|
||||||
// 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(GameRules.DO_MOB_LOOT)) {
|
if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof PlayerEntity && event.getEntityLiving().world.getGameRules().getBoolean("doMobLoot")) {
|
||||||
//Drop Solidified XP
|
//Drop Solidified XP
|
||||||
if (event.getEntityLiving() instanceof CreatureEntity) {
|
if (event.getEntityLiving() instanceof EntityCreature) {
|
||||||
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().getPosX(), event.getEntityLiving().getPosY(), event.getEntityLiving().getPosZ(), new ItemStack(ActuallyItems.SOLIDIFIED_EXPERIENCE.get(), event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1)));
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,13 +70,18 @@ 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) {
|
||||||
ExperienceOrbEntity orb = new ExperienceOrbEntity(world, player.getPosX() + 0.5, player.getPosY() + 0.5, player.getPosZ() + 0.5, amount);
|
EntityXPOrb orb = new EntityXPOrb(world, player.posX + 0.5, player.posY + 0.5, player.posZ + 0.5, amount);
|
||||||
orb.getPersistentData().putBoolean(ActuallyAdditions.MODID + "FromSolidified", true);
|
orb.getEntityData().putBoolean(ActuallyAdditions.MODID + "FromSolidified", true);
|
||||||
world.addEntity(orb);
|
world.addEntity(orb);
|
||||||
} else {
|
} else {
|
||||||
player.addExperienceLevel(amount);
|
player.addExperience(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ActionResult.resultSuccess(stack);
|
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return EnumRarity.UNCOMMON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,142 +1,141 @@
|
||||||
// TODO: [port] REMOVE THIS CLASS, NO longer needed
|
/*
|
||||||
///*
|
* This file ("ItemSpawnerChanger.java") is part of the Actually Additions mod for Minecraft.
|
||||||
// * This file ("ItemSpawnerChanger.java") is part of the Actually Additions mod for Minecraft.
|
* It is created and owned by Ellpeck and distributed
|
||||||
// * It is created and owned by Ellpeck and distributed
|
* under the Actually Additions License to be found at
|
||||||
// * under the Actually Additions License to be found at
|
* http://ellpeck.de/actaddlicense
|
||||||
// * http://ellpeck.de/actaddlicense
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
// * 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.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import net.minecraft.block.BlockState;
|
||||||
//import net.minecraft.block.BlockState;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
//import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.entity.EntityList;
|
||||||
//import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
//import net.minecraft.entity.EntityLivingBase;
|
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.nbt.CompoundNBT;
|
||||||
//import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||||
//import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
//import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||||
//import net.minecraft.tileentity.TileEntityMobSpawner;
|
import net.minecraft.util.Direction;
|
||||||
//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.ResourceLocation;
|
||||||
//import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.math.BlockPos;
|
||||||
//import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
//import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.world.World;
|
||||||
//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() {
|
||||||
// public ItemSpawnerChanger() {
|
super(name);
|
||||||
// super();
|
this.setMaxStackSize(1);
|
||||||
// this.setMaxStackSize(1);
|
}
|
||||||
// }
|
|
||||||
//
|
@Override
|
||||||
// @Override
|
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||||
// public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
if (!world.isRemote) {
|
||||||
// if (!world.isRemote) {
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
// ItemStack stack = player.getHeldItemMainhand();
|
if (player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||||
// if (player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
// TileEntity tile = world.getTileEntity(pos);
|
if (tile instanceof TileEntityMobSpawner) {
|
||||||
// if (tile instanceof TileEntityMobSpawner) {
|
String entity = this.getStoredEntity(stack);
|
||||||
// String entity = this.getStoredEntity(stack);
|
if (entity != null) {
|
||||||
// if (entity != null) {
|
MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) tile).getSpawnerBaseLogic();
|
||||||
// MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) tile).getSpawnerBaseLogic();
|
|
||||||
//
|
//This is a hacky way to remove the spawn potentials that make the spawner reset from time to time
|
||||||
// //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
|
||||||
// //Don't judge, there isn't a method for it and it's better than Reflection hackiness
|
CompoundNBT compound = new CompoundNBT();
|
||||||
// CompoundNBT compound = new CompoundNBT();
|
logic.writeToNBT(compound);
|
||||||
// logic.writeToNBT(compound);
|
compound.removeTag("SpawnPotentials");
|
||||||
// compound.removeTag("SpawnPotentials");
|
compound.removeTag("SpawnData");
|
||||||
// compound.removeTag("SpawnData");
|
logic.readFromNBT(compound);
|
||||||
// logic.readFromNBT(compound);
|
|
||||||
//
|
logic.setEntityId(new ResourceLocation(entity));
|
||||||
// logic.setEntityId(new ResourceLocation(entity));
|
|
||||||
//
|
tile.markDirty();
|
||||||
// tile.markDirty();
|
|
||||||
//
|
BlockState state = world.getBlockState(pos);
|
||||||
// BlockState state = world.getBlockState(pos);
|
world.notifyBlockUpdate(pos, state, state, 3);
|
||||||
// world.notifyBlockUpdate(pos, state, state, 3);
|
|
||||||
//
|
ItemPhantomConnector.clearStorage(stack, "Entity");
|
||||||
// ItemPhantomConnector.clearStorage(stack, "Entity");
|
|
||||||
//
|
if (!player.isCreative()) {
|
||||||
// if (!player.isCreative()) {
|
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
||||||
// player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
}
|
||||||
// }
|
|
||||||
//
|
return EnumActionResult.SUCCESS;
|
||||||
// return EnumActionResult.SUCCESS;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
return EnumActionResult.FAIL;
|
||||||
// return EnumActionResult.FAIL;
|
}
|
||||||
// }
|
|
||||||
//
|
@Override
|
||||||
// @Override
|
public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase entity, Hand hand) {
|
||||||
// public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase entity, Hand hand) {
|
if (!player.world.isRemote) {
|
||||||
// if (!player.world.isRemote) {
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
// ItemStack stack = player.getHeldItemMainhand();
|
if (this.getStoredEntity(stack) == null) {
|
||||||
// if (this.getStoredEntity(stack) == null) {
|
if (this.storeClickedEntity(stack, entity)) {
|
||||||
// if (this.storeClickedEntity(stack, entity)) {
|
entity.setDead();
|
||||||
// entity.setDead();
|
}
|
||||||
// }
|
}
|
||||||
// }
|
return true;
|
||||||
// return true;
|
}
|
||||||
// }
|
return false;
|
||||||
// return false;
|
}
|
||||||
// }
|
|
||||||
//
|
private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) {
|
||||||
// private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) {
|
if (!stack.hasTagCompound()) {
|
||||||
// if (!stack.hasTagCompound()) {
|
stack.setTagCompound(new CompoundNBT());
|
||||||
// stack.setTagCompound(new CompoundNBT());
|
}
|
||||||
// }
|
|
||||||
//
|
if (!(entity instanceof PlayerEntity) && entity.isNonBoss()) {
|
||||||
// if (!(entity instanceof PlayerEntity) && entity.isNonBoss()) {
|
ResourceLocation entityLoc = EntityList.getKey(entity.getClass());
|
||||||
// ResourceLocation entityLoc = EntityList.getKey(entity.getClass());
|
if (entityLoc != null) {
|
||||||
// if (entityLoc != null) {
|
String entityName = entityLoc.toString();
|
||||||
// String entityName = entityLoc.toString();
|
if (entityName != null && !entityName.isEmpty()) {
|
||||||
// if (entityName != null && !entityName.isEmpty()) {
|
for (String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()) {
|
||||||
// for (String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()) {
|
if (entityName.equals(name)) {
|
||||||
// if (entityName.equals(name)) {
|
return false;
|
||||||
// return false;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
stack.getTagCompound().setString("Entity", entityName);
|
||||||
// stack.getTagCompound().setString("Entity", entityName);
|
return true;
|
||||||
// return true;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
return false;
|
||||||
// return false;
|
}
|
||||||
// }
|
|
||||||
//
|
private String getStoredEntity(ItemStack stack) {
|
||||||
// private String getStoredEntity(ItemStack stack) {
|
if (stack.hasTagCompound()) {
|
||||||
// if (stack.hasTagCompound()) {
|
String entity = stack.getTagCompound().getString("Entity");
|
||||||
// String entity = stack.getTagCompound().getString("Entity");
|
if (entity != null && !entity.isEmpty()) {
|
||||||
// if (entity != null && !entity.isEmpty()) {
|
return entity;
|
||||||
// return entity;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
return null;
|
||||||
// return null;
|
}
|
||||||
// }
|
|
||||||
//
|
@Override
|
||||||
// @Override
|
public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
||||||
// public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
String entity = this.getStoredEntity(stack);
|
||||||
// String entity = this.getStoredEntity(stack);
|
if (entity != null) {
|
||||||
// if (entity != null) {
|
list.add("Entity: " + entity);
|
||||||
// list.add("Entity: " + entity);
|
list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc"));
|
||||||
// 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.BatEntity;
|
import net.minecraft.entity.passive.EntityBat;
|
||||||
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.SwordItem;
|
import net.minecraft.item.ItemSword;
|
||||||
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.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.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(ActuallyItems.defaultProps().maxStackSize(1));
|
super(name);
|
||||||
|
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,23 +67,27 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getDurabilityForDisplay(ItemStack stack) {
|
public double getDurabilityForDisplay(ItemStack stack) {
|
||||||
PlayerEntity player = ClientProxy.getCurrentPlayer();
|
PlayerEntity player = ActuallyAdditions.PROXY.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 = ClientProxy.getCurrentPlayer();
|
PlayerEntity player = ActuallyAdditions.PROXY.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,21 +97,19 @@ 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 BatEntity) {
|
if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) {
|
||||||
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) {
|
||||||
// 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()) && stack.getItem() instanceof ItemSword) {
|
||||||
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) {
|
||||||
LivingEntity entityLiving = event.getEntityLiving();
|
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)));
|
||||||
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)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,12 +139,12 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME) {
|
if (wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME) {
|
||||||
player.abilities.allowFlying = true;
|
player.capabilities.allowFlying = true;
|
||||||
|
|
||||||
if (player.abilities.isFlying) {
|
if (player.capabilities.isFlying) {
|
||||||
data.batWingsFlyTime++;
|
data.batWingsFlyTime++;
|
||||||
|
|
||||||
if (player.world.getWorldInfo().getGameTime() % 10 == 0) {
|
if (player.world.getTotalWorldTime() % 10 == 0) {
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,21 +155,21 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
data.shouldDisableBatWings = true;
|
data.shouldDisableBatWings = true;
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
|
|
||||||
player.abilities.allowFlying = false;
|
player.capabilities.allowFlying = false;
|
||||||
player.abilities.isFlying = false;
|
player.capabilities.isFlying = false;
|
||||||
player.abilities.disableDamage = false;
|
player.capabilities.disableDamage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tryDeduct && data.batWingsFlyTime > 0) {
|
if (tryDeduct && data.batWingsFlyTime > 0) {
|
||||||
int deductTime = 0;
|
int deductTime = 0;
|
||||||
|
|
||||||
if (!player.abilities.isFlying) {
|
if (!player.capabilities.isFlying) {
|
||||||
deductTime = 2;
|
deductTime = 2;
|
||||||
} else {
|
} else {
|
||||||
BlockPos pos = new BlockPos(player.getPosX(), player.getPosY() + player.getHeight(), player.getPosZ());
|
BlockPos pos = new BlockPos(player.posX, player.posY + player.height, player.posZ);
|
||||||
BlockState state = player.world.getBlockState(pos);
|
BlockState state = player.world.getBlockState(pos);
|
||||||
if (state.isSolidSide(player.world, pos, Direction.DOWN)) {
|
if (state != null && state.isSideSolid(player.world, pos, Direction.DOWN)) {
|
||||||
deductTime = 10;
|
deductTime = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +177,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.getWorldInfo().getGameTime() % 10 == 0) {
|
if (player.world.getTotalWorldTime() % 10 == 0) {
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,16 +189,21 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (data.hasBatWings) {
|
if (data.hasBatWings) {
|
||||||
player.abilities.allowFlying = true;
|
player.capabilities.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.abilities.allowFlying = false;
|
player.capabilities.allowFlying = false;
|
||||||
player.abilities.isFlying = false;
|
player.capabilities.isFlying = false;
|
||||||
player.abilities.disableDamage = false;
|
player.capabilities.disableDamage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return EnumRarity.EPIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ 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 TranslationTextComponent(this.getNameForTranslation());
|
// return new TextComponentTranslation(this.getNameForTranslation());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue