Another pass through items/entities

This commit is contained in:
Vincent Lee committed 2019-02-28 23:05:19 -06:00
1 parent 4ad7e675eb
commit 95fc132f9f
74 files changed
+642 -708

No files matched your search

@@ -10,11 +10,9 @@
*/
package vazkii.botania.api.internal;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -120,7 +118,7 @@ public class DummyMethodHandler implements IInternalMethodHandler {
@Override
public ItemStack getSubTileAsStack(ResourceLocation subTile) {
return new ItemStack(Blocks.STONE, 0, 0);
return ItemStack.EMPTY;
}
@Override
@@ -156,7 +154,7 @@ public class DummyMethodHandler implements IInternalMethodHandler {
@Override
public ItemStack getBindDisplayForFlowerType(SubTileEntity e) {
return new ItemStack(Blocks.STONE, 0, 0);
return ItemStack.EMPTY;
}
@Override
@@ -28,9 +28,11 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.state.properties.PistonType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.storage.WorldSavedData;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
@@ -81,11 +83,11 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
public void onReplaced(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newState, boolean isMoving) {
// todo 1.13 utilize isMoving?
if(!world.isRemote)
mapCoords(world.getDimension().getId(), pos, 2);
mapCoords(world.getDimension().getType(), pos, 2);
}
private void mapCoords(int world, BlockPos pos, int time) {
coordsToCheck.put(new DimWithPos(world, pos), time);
private void mapCoords(DimensionType type, BlockPos pos, int time) {
coordsToCheck.put(new DimWithPos(type, pos), time);
}
private void decrCoords(DimWithPos key) {
@@ -117,7 +119,7 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
return false;
if(!player.isSneaking()) {
playerPositions.put(player.getUniqueID(), new DimWithPos(world.getDimension().getId(), pos));
playerPositions.put(player.getUniqueID(), new DimWithPos(world.getDimension().getType(), pos));
world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 0.5F, 1F);
} else {
spawnAsEntity(world, pos, new ItemStack(this));
@@ -154,7 +156,7 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
Collection<String> tags = nbttagcompound.keySet();
for(String key : tags) {
INBTBase tag = nbttagcompound.getTag(key);
INBTBase tag = nbttagcompound.get(key);
if(tag instanceof NBTTagString) {
String value = tag.getString();
@@ -167,20 +169,20 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
@Override
public NBTTagCompound write(@Nonnull NBTTagCompound nbttagcompound) {
for(DimWithPos s : ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.keySet())
nbttagcompound.setString(s.toString(), ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(s).toString());
nbttagcompound.putString(s.toString(), ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(s).toString());
return nbttagcompound;
}
public static WorldData get(World world) {
if(world.getMapStorage() == null)
if(world.getSavedDataStorage() == null)
return null;
WorldData data = world.getMapStorage().getOrLoadData(WorldData::new, ID);
WorldData data = world.getSavedData(DimensionType.OVERWORLD, WorldData::new, ID);
if (data == null) {
data = new WorldData(ID);
data.markDirty();
world.getMapStorage().setData(ID, data);
world.setSavedData(DimensionType.OVERWORLD, ID, data);
}
return data;
}
@@ -206,9 +208,9 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
DimWithPos newPos;
{
int worldId = s.dim, x = s.blockPos.getX(), y = s.blockPos.getY(), z = s.blockPos.getZ();
int x = s.blockPos.getX(), y = s.blockPos.getY(), z = s.blockPos.getZ();
BlockPos pos = s.blockPos;
World world = server.getWorld(worldId);
World world = server.getWorld(s.dim);
if(world.isAirBlock(pos.offset(dir)))
world.setBlockState(pos.offset(dir), ModBlocks.pistonRelay.getDefaultState());
else if(!world.isRemote) {
@@ -216,14 +218,13 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
world.spawnEntity(new EntityItem(world, x + dir.getXOffset(), y + dir.getYOffset(), z + dir.getZOffset(), stack));
}
checkedCoords.add(s);
newPos = new DimWithPos(world.getDimension().getId(), pos.offset(dir));
newPos = new DimWithPos(world.getDimension().getType(), pos.offset(dir));
}
if(mappedPositions.containsKey(s)) {
DimWithPos pos = mappedPositions.get(s);
int worldId = pos.dim;
BlockPos pos2 = pos.blockPos;
World world = server.getWorld(worldId);
World world = server.getWorld(pos.dim);
IBlockState srcState = world.getBlockState(pos2);
TileEntity tile = world.getTileEntity(pos2);
@@ -234,7 +235,7 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
if(world.isAirBlock(pos2.offset(dir)) || destMat.isReplaceable()) {
world.setBlockState(pos2, Blocks.AIR.getDefaultState());
world.setBlockState(pos2.offset(dir), srcState, 1 | 2);
mappedPositions.put(s, new DimWithPos(world.getDimension().getId(), pos2.offset(dir)));
mappedPositions.put(s, new DimWithPos(world.getDimension().getType(), pos2.offset(dir)));
}
}
@@ -267,34 +268,35 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl
}
public static class DimWithPos {
public final int dim;
public final DimensionType dim;
public final BlockPos blockPos;
public DimWithPos(int dim, BlockPos pos) {
public DimWithPos(DimensionType dim, BlockPos pos) {
this.dim = dim;
blockPos = pos;
}
@Override
public int hashCode() {
return 31 * dim ^ blockPos.hashCode();
return 31 * dim.hashCode() ^ blockPos.hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof DimWithPos
&& dim == ((DimWithPos) o).dim
&& dim.equals(((DimWithPos) o).dim)
&& blockPos.equals(((DimWithPos) o).blockPos);
}
@Override
public String toString() {
return dim + ":" + blockPos.getX() + ":" + blockPos.getY() + ":" + blockPos.getZ();
return dim.toString() + "|" + blockPos.getX() + "|" + blockPos.getY() + "|" + blockPos.getZ();
}
public static DimWithPos fromString(String s) {
String[] split = s.split(":");
return new DimWithPos(Integer.parseInt(split[0]), new BlockPos(Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3])));
String[] split = s.split("\\|");
DimensionType type = DimensionType.byName(new ResourceLocation(split[0]));
return new DimWithPos(type, new BlockPos(Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3])));
}
}
@@ -619,7 +619,7 @@ public final class ModBlocks {
r.register(new ItemBlockMod(livingwoodFramed, props).setRegistryName(livingwoodFramed.getRegistryName()));
r.register(new ItemBlockMod(livingwoodPatternFramed, props).setRegistryName(livingwoodPatternFramed.getRegistryName()));
r.register(new ItemBlockMod(livingwoodGlimmering, props).setRegistryName(livingwoodGlimmering.getRegistryName()));
r.register(new ItemBlockSpecialFlower(specialFlower).setRegistryName(specialFlower.getRegistryName()));
r.register(new ItemBlockSpecialFlower(specialFlower, props).setRegistryName(specialFlower.getRegistryName()));
r.register(new ItemBlockMod(manaSpreader, props).setRegistryName(manaSpreader.getRegistryName()));
r.register(new ItemBlockMod(redstoneSpreader, props).setRegistryName(redstoneSpreader.getRegistryName()));
r.register(new ItemBlockMod(elvenSpreader, props).setRegistryName(elvenSpreader.getRegistryName()));
@@ -979,6 +979,28 @@ public final class ModBlocks {
}
}
public static Block getCarpet(EnumDyeColor color) {
switch (color) {
default:
case WHITE: return Blocks.WHITE_CARPET;
case ORANGE: return Blocks.ORANGE_CARPET;
case MAGENTA: return Blocks.ORANGE_CARPET;
case LIGHT_BLUE: return Blocks.ORANGE_CARPET;
case YELLOW: return Blocks.ORANGE_CARPET;
case LIME: return Blocks.ORANGE_CARPET;
case PINK: return Blocks.ORANGE_CARPET;
case GRAY: return Blocks.ORANGE_CARPET;
case LIGHT_GRAY: return Blocks.ORANGE_CARPET;
case CYAN: return Blocks.ORANGE_CARPET;
case PURPLE: return Blocks.ORANGE_CARPET;
case BLUE: return Blocks.ORANGE_CARPET;
case BROWN: return Blocks.ORANGE_CARPET;
case GREEN: return Blocks.ORANGE_CARPET;
case RED: return Blocks.ORANGE_CARPET;
case BLACK: return Blocks.ORANGE_CARPET;
}
}
public static Block getBuriedPetal(EnumDyeColor color) {
switch (color) {
default:
@@ -165,7 +165,7 @@ public class BlockFloatingFlower extends BlockMod implements ILexiconable, IInfu
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty()) {
IFloatingFlower flower = (IFloatingFlower) world.getTileEntity(pos);
@@ -184,7 +184,7 @@ public class BlockFloatingFlower extends BlockMod implements ILexiconable, IInfu
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
}
if(!player.capabilities.isCreativeMode)
if(!player.abilities.isCreativeMode)
stack.shrink(1);
return true;
}
@@ -14,8 +14,7 @@ import baubles.api.BaublesApi;
import baubles.common.network.PacketHandler;
import baubles.common.network.PacketSync;
import net.minecraft.block.Block;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -27,7 +26,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.items.IItemHandlerModifiable;
import vazkii.botania.api.BotaniaAPIClient;
import vazkii.botania.api.corporea.CorporeaHelper;
@@ -24,58 +24,58 @@ public final class ItemNBTHelper {
// SETTERS ///////////////////////////////////////////////////////////////////
public static void setBoolean(ItemStack stack, String tag, boolean b) {
stack.getOrCreateTag().setBoolean(tag, b);
stack.getOrCreateTag().putBoolean(tag, b);
}
public static void setByte(ItemStack stack, String tag, byte b) {
stack.getOrCreateTag().setByte(tag, b);
stack.getOrCreateTag().putByte(tag, b);
}
public static void setShort(ItemStack stack, String tag, short s) {
stack.getOrCreateTag().setShort(tag, s);
stack.getOrCreateTag().putShort(tag, s);
}
public static void setInt(ItemStack stack, String tag, int i) {
stack.getOrCreateTag().setInt(tag, i);
stack.getOrCreateTag().putInt(tag, i);
}
public static void setIntArray(ItemStack stack, String tag, int[] val) {
stack.getOrCreateTag().setIntArray(tag, val);
stack.getOrCreateTag().putIntArray(tag, val);
}
public static void setLong(ItemStack stack, String tag, long l) {
stack.getOrCreateTag().setLong(tag, l);
stack.getOrCreateTag().putLong(tag, l);
}
public static void setFloat(ItemStack stack, String tag, float f) {
stack.getOrCreateTag().setFloat(tag, f);
stack.getOrCreateTag().putFloat(tag, f);
}
public static void setDouble(ItemStack stack, String tag, double d) {
stack.getOrCreateTag().setDouble(tag, d);
stack.getOrCreateTag().putDouble(tag, d);
}
public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) {
if(!tag.equalsIgnoreCase("ench")) // not override the enchantments
stack.getOrCreateTag().setTag(tag, cmp);
stack.getOrCreateTag().put(tag, cmp);
}
public static void setString(ItemStack stack, String tag, String s) {
stack.getOrCreateTag().setString(tag, s);
stack.getOrCreateTag().putString(tag, s);
}
public static void setList(ItemStack stack, String tag, NBTTagList list) {
stack.getOrCreateTag().setTag(tag, list);
stack.getOrCreateTag().put(tag, list);
}
public static void removeEntry(ItemStack stack, String tag) {
stack.getOrCreateTag().removeTag(tag);
stack.getOrCreateTag().remove(tag);
}
// GETTERS ///////////////////////////////////////////////////////////////////
public static boolean verifyExistance(ItemStack stack, String tag) {
return !stack.isEmpty() && stack.getOrCreateTag().hasKey(tag);
return !stack.isEmpty() && stack.getOrCreateTag().contains(tag);
}
public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) {
@@ -11,7 +11,7 @@ import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraft.world.storage.loot.conditions.LootConditionManager;
import net.minecraft.world.storage.loot.functions.LootFunctionManager;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@@ -188,12 +188,12 @@ public class EntityBabylonWeapon extends EntityThrowableCopy implements ILightPr
@Override
public void writeAdditional(@Nonnull NBTTagCompound cmp) {
super.writeAdditional(cmp);
cmp.setBoolean(TAG_CHARGING, isCharging());
cmp.setInt(TAG_VARIETY, getVariety());
cmp.setInt(TAG_CHARGE_TICKS, getChargeTicks());
cmp.setInt(TAG_LIVE_TICKS, getLiveTicks());
cmp.setInt(TAG_DELAY, getDelay());
cmp.setFloat(TAG_ROTATION, getRotation());
cmp.putBoolean(TAG_CHARGING, isCharging());
cmp.putInt(TAG_VARIETY, getVariety());
cmp.putInt(TAG_CHARGE_TICKS, getChargeTicks());
cmp.putInt(TAG_LIVE_TICKS, getLiveTicks());
cmp.putInt(TAG_DELAY, getDelay());
cmp.putFloat(TAG_ROTATION, getRotation());
}
@Override
@@ -43,7 +43,7 @@ public class EntityEnderAirBottle extends EntityThrowable {
@Override
protected void onImpact(@Nonnull RayTraceResult pos) {
if(pos.getBlockPos() != null && !world.isRemote) {
if(pos.type == RayTraceResult.Type.BLOCK && !world.isRemote) {
List<BlockPos> coordsList = getCoordsToPut(pos.getBlockPos());
world.playEvent(2002, new BlockPos(this), 8);
@@ -28,7 +28,6 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.Vector3;
@@ -156,7 +155,7 @@ public class EntityMagicMissile extends EntityThrowable {
@Override
public void writeAdditional(NBTTagCompound cmp) {
super.writeAdditional(cmp);
cmp.setInt(TAG_TIME, time);
cmp.putInt(TAG_TIME, time);
}
@Override
@@ -110,8 +110,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
}
@Override
protected void entityInit() {
super.entityInit();
protected void registerData() {
super.registerData();
dataManager.register(COLOR, 0);
dataManager.register(MANA, 0);
dataManager.register(START_MANA, 0);
@@ -171,7 +171,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
setFlag(6, isGlowing());
}
onEntityUpdate();
baseTick();
}
if (throwableShake > 0)
@@ -211,7 +211,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
}
else
{
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().grow(0.30000001192092896D);
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (raytraceresult1 != null)
@@ -248,7 +248,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
if (raytraceresult != null)
{
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.PORTAL)
if (raytraceresult.type == RayTraceResult.Type.BLOCK && world.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.NETHER_PORTAL)
{
setPortal(raytraceresult.getBlockPos());
}
@@ -308,11 +308,11 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
}
@Override
public void onUpdate() {
public void tick() {
setTicksExisted(getTicksExisted() + 1);
superUpdate();
if(!fake && !isDead && !scanBeam)
if(!fake && isAlive() && !scanBeam)
ping();
ILensEffect lens = getLensInstance();
@@ -373,8 +373,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
this.noParticles = noParticles;
int iterations = 0;
while(!isDead && iterations < ConfigHandler.spreaderTraceTime) {
onUpdate();
while(isAlive() && iterations < ConfigHandler.spreaderTraceTime) {
tick();
iterations++;
}
@@ -385,73 +385,73 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
}
@Override
public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeEntityToNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_TICKS_EXISTED, getTicksExisted());
par1nbtTagCompound.setInteger(TAG_COLOR, getColor());
par1nbtTagCompound.setInteger(TAG_MANA, getMana());
par1nbtTagCompound.setInteger(TAG_STARTING_MANA, getStartingMana());
par1nbtTagCompound.setInteger(TAG_MIN_MANA_LOSS, getMinManaLoss());
par1nbtTagCompound.setFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick());
par1nbtTagCompound.setFloat(TAG_GRAVITY, getGravity());
public void writeAdditional(NBTTagCompound par1nbtTagCompound) {
super.writeAdditional(par1nbtTagCompound);
par1nbtTagCompound.putInt(TAG_TICKS_EXISTED, getTicksExisted());
par1nbtTagCompound.putInt(TAG_COLOR, getColor());
par1nbtTagCompound.putInt(TAG_MANA, getMana());
par1nbtTagCompound.putInt(TAG_STARTING_MANA, getStartingMana());
par1nbtTagCompound.putInt(TAG_MIN_MANA_LOSS, getMinManaLoss());
par1nbtTagCompound.putFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick());
par1nbtTagCompound.putFloat(TAG_GRAVITY, getGravity());
ItemStack stack = getSourceLens();
NBTTagCompound lensCmp = new NBTTagCompound();
if(!stack.isEmpty())
lensCmp = stack.writeToNBT(lensCmp);
par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp);
lensCmp = stack.write(lensCmp);
par1nbtTagCompound.put(TAG_LENS_STACK, lensCmp);
BlockPos coords = getBurstSourceBlockPos();
par1nbtTagCompound.setInteger(TAG_SPREADER_X, coords.getX());
par1nbtTagCompound.setInteger(TAG_SPREADER_Y, coords.getY());
par1nbtTagCompound.setInteger(TAG_SPREADER_Z, coords.getZ());
par1nbtTagCompound.putInt(TAG_SPREADER_X, coords.getX());
par1nbtTagCompound.putInt(TAG_SPREADER_Y, coords.getY());
par1nbtTagCompound.putInt(TAG_SPREADER_Z, coords.getZ());
par1nbtTagCompound.setDouble(TAG_LAST_MOTION_X, motionX);
par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY);
par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ);
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_X, motionX);
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_Y, motionY);
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_Z, motionZ);
UUID identity = getShooterUUID();
boolean hasShooter = identity != null;
par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter);
par1nbtTagCompound.putBoolean(TAG_HAS_SHOOTER, hasShooter);
if(hasShooter) {
par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits());
par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits());
par1nbtTagCompound.putLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits());
par1nbtTagCompound.putLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits());
}
}
@Override
public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readEntityFromNBT(par1nbtTagCompound);
setTicksExisted(par1nbtTagCompound.getInteger(TAG_TICKS_EXISTED));
setColor(par1nbtTagCompound.getInteger(TAG_COLOR));
setMana(par1nbtTagCompound.getInteger(TAG_MANA));
setStartingMana(par1nbtTagCompound.getInteger(TAG_STARTING_MANA));
setMinManaLoss(par1nbtTagCompound.getInteger(TAG_MIN_MANA_LOSS));
setManaLossPerTick(par1nbtTagCompound.getFloat(TAG_TICK_MANA_LOSS));
setGravity(par1nbtTagCompound.getFloat(TAG_GRAVITY));
public void readAdditional(NBTTagCompound cmp) {
super.readAdditional(cmp);
setTicksExisted(cmp.getInt(TAG_TICKS_EXISTED));
setColor(cmp.getInt(TAG_COLOR));
setMana(cmp.getInt(TAG_MANA));
setStartingMana(cmp.getInt(TAG_STARTING_MANA));
setMinManaLoss(cmp.getInt(TAG_MIN_MANA_LOSS));
setManaLossPerTick(cmp.getFloat(TAG_TICK_MANA_LOSS));
setGravity(cmp.getFloat(TAG_GRAVITY));
NBTTagCompound lensCmp = par1nbtTagCompound.getCompoundTag(TAG_LENS_STACK);
ItemStack stack = new ItemStack(lensCmp);
NBTTagCompound lensCmp = cmp.getCompound(TAG_LENS_STACK);
ItemStack stack = ItemStack.read(lensCmp);
if(!stack.isEmpty())
setSourceLens(stack);
else setSourceLens(ItemStack.EMPTY);
int x = par1nbtTagCompound.getInteger(TAG_SPREADER_X);
int y = par1nbtTagCompound.getInteger(TAG_SPREADER_Y);
int z = par1nbtTagCompound.getInteger(TAG_SPREADER_Z);
int x = cmp.getInt(TAG_SPREADER_X);
int y = cmp.getInt(TAG_SPREADER_Y);
int z = cmp.getInt(TAG_SPREADER_Z);
setBurstSourceCoords(new BlockPos(x, y, z));
double lastMotionX = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_X);
double lastMotionY = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Y);
double lastMotionZ = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Z);
double lastMotionX = cmp.getDouble(TAG_LAST_MOTION_X);
double lastMotionY = cmp.getDouble(TAG_LAST_MOTION_Y);
double lastMotionZ = cmp.getDouble(TAG_LAST_MOTION_Z);
setMotion(lastMotionX, lastMotionY, lastMotionZ);
boolean hasShooter = par1nbtTagCompound.getBoolean(TAG_HAS_SHOOTER);
boolean hasShooter = cmp.getBoolean(TAG_HAS_SHOOTER);
if(hasShooter) {
long most = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_MOST);
long least = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_LEAST);
long most = cmp.getLong(TAG_SHOOTER_UUID_MOST);
long least = cmp.getLong(TAG_SHOOTER_UUID_LEAST);
UUID identity = getShooterUUID();
if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits())
shooterIdentity = new UUID(most, least);
@@ -459,7 +459,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
}
public void particles() {
if(isDead || !world.isRemote)
if(!isAlive() || !world.isRemote)
return;
ILensEffect lens = getLensInstance();
@@ -521,7 +521,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
currentPos = Vector3.fromEntity(this);
diffVec = oldPos.subtract(currentPos);
if(getEntityData().hasKey(ItemTinyPlanet.TAG_ORBIT))
if(getEntityData().contains(ItemTinyPlanet.TAG_ORBIT))
break;
} while(Math.abs(diffVec.mag()) > distance);
@@ -546,7 +546,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
boolean collided = false;
boolean dead = false;
if(rtr.entityHit == null) {
if(rtr.entity == null) {
TileEntity tile = world.getTileEntity(rtr.getBlockPos());
IBlockState state = world.getBlockState(rtr.getBlockPos());
Block block = state.getBlock();
@@ -584,7 +584,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
if(collided && !hasAlreadyCollidedAt(rtr.getBlockPos()))
alreadyCollidedAt.add(rtr.getBlockPos());
if(dead && !isDead) {
if(dead && isAlive()) {
if(!fake) {
Color color = new Color(getColor());
float r = color.getRed() / 255F;
@@ -625,12 +625,12 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
}
@Override
public void setDead() {
super.setDead();
public void remove() {
super.remove();
if(!fake) {
TileEntity tile = getShooter();
if(tile != null && tile instanceof IManaSpreader)
if(tile instanceof IManaSpreader)
((IManaSpreader) tile).setCanShoot(true);
} else setDeathTicksForFakeParticle();
}
@@ -795,15 +795,14 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst, ILig
return true;
TileEntity tile = getShooter();
return tile != null
&& tile instanceof IManaSpreader
return tile instanceof IManaSpreader
&& (getMana() != getStartingMana() && fullManaLastTick
|| Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4);
}
private void incrementFakeParticleTick() {
TileEntity tile = getShooter();
if(tile != null && tile instanceof IManaSpreader) {
if(tile instanceof IManaSpreader) {
IManaSpreader spreader = (IManaSpreader) tile;
spreader.setBurstParticleTick(spreader.getBurstParticleTick()+2);
if(spreader.getLastBurstDeathTick() != -1 && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick())
@@ -94,9 +94,9 @@ public class EntityManaStorm extends Entity {
@Override
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
cmp.setInt(TAG_TIME, liveTime);
cmp.setInt(TAG_BURSTS_FIRED, burstsFired);
cmp.setInt(TAG_DEATH_TIME, deathTime);
cmp.putInt(TAG_TIME, liveTime);
cmp.putInt(TAG_BURSTS_FIRED, burstsFired);
cmp.putInt(TAG_DEATH_TIME, deathTime);
}
}
@@ -54,7 +54,7 @@ public class EntityPinkWither extends EntityWither {
double d10 = getHeadX(j);
double d2 = getHeadY(j);
double d4 = getHeadZ(j);
world.spawnParticle(Particles.HEART, d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D);
world.addParticle(Particles.HEART, d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D);
}
}
@@ -104,7 +104,7 @@ public class EntityPixie extends EntityFlying implements ILightProvider {
} else target.attackEntityFrom(DamageSource.causeMobDamage(this), damage);
if(effect != null && !(target instanceof EntityPlayer))
target.addPotionEffect(effect);
setDead();
remove();
}
}
@@ -124,7 +124,7 @@ public class EntityPixie extends EntityFlying implements ILightProvider {
if(!world.isRemote
&& (getAttackTarget() == null || ticksExisted > 200))
setDead();
remove();
boolean dark = getPixieType() == 1;
if(world.isRemote)
@@ -141,7 +141,7 @@ public class EntityPixie extends EntityFlying implements ILightProvider {
}
@Override
protected boolean canDespawn() {
public boolean canDespawn() {
return false;
}
@@ -140,7 +140,7 @@ public class EntityPoolMinecart extends EntityMinecart {
TileEntity tile_ = world.getTileEntity(posP);
TilePump pump = (TilePump) tile_;
if(tile != null && tile instanceof IManaPool) {
if(tile instanceof IManaPool) {
IManaPool pool = (IManaPool) tile;
EnumFacing pumpDir = world.getBlockState(posP).get(BotaniaStateProps.CARDINALS);
boolean did = false;
@@ -194,7 +194,7 @@ public class EntityPoolMinecart extends EntityMinecart {
@Override
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
super.writeAdditional(cmp);
cmp.setInt(TAG_MANA, getMana());
cmp.putInt(TAG_MANA, getMana());
}
@Override
@@ -80,8 +80,8 @@ public class EntitySignalFlare extends Entity {
@Override
protected void writeAdditional(@Nonnull NBTTagCompound nbttagcompound) {
nbttagcompound.setInt(COLOR_TAG, getColor());
nbttagcompound.setInt(FIRED_Y_TAG, getFiredAt());
nbttagcompound.putInt(COLOR_TAG, getColor());
nbttagcompound.putInt(FIRED_Y_TAG, getFiredAt());
}
public void setColor(int color) {
@@ -290,8 +290,8 @@ public class EntitySpark extends Entity implements ISparkEntity {
@Override
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
cmp.setInt(TAG_UPGRADE, getUpgrade().ordinal());
cmp.setInt(TAG_INVIS, isInvisible() ? 1 : 0);
cmp.putInt(TAG_UPGRADE, getUpgrade().ordinal());
cmp.putInt(TAG_INVIS, isInvisible() ? 1 : 0);
}
@Override
@@ -105,7 +105,7 @@ public class EntityThornChakram extends EntityThrowable {
double r = 0.1;
double m = 0.1;
for(int i = 0; i < 3; i++)
world.spawnParticle(Particles.FLAME, posX + r * (Math.random() - 0.5), posY + r * (Math.random() - 0.5), posZ + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5));
world.addParticle(Particles.FLAME, posX + r * (Math.random() - 0.5), posY + r * (Math.random() - 0.5), posZ + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5));
}
// Server state control
@@ -216,15 +216,15 @@ public class EntityThornChakram extends EntityThrowable {
public void writeAdditional(NBTTagCompound compound) {
super.writeAdditional(compound);
if(!stack.isEmpty()) {
compound.setTag("fly_stack", stack.write(new NBTTagCompound()));
compound.put("fly_stack", stack.write(new NBTTagCompound()));
}
compound.setBoolean("flare", isFire());
compound.putBoolean("flare", isFire());
}
@Override
public void readAdditional(NBTTagCompound compound) {
super.readAdditional(compound);
if(compound.hasKey("fly_stack")) {
if(compound.contains("fly_stack")) {
stack = ItemStack.read(compound.getCompound("fly_stack"));
}
setFire(compound.getBoolean("flare"));
@@ -231,7 +231,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
if (this.isInWater()) {
for(int j = 0; j < 4; ++j) {
float f3 = 0.25F;
this.world.spawnParticle(Particles.BUBBLE, this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ);
this.world.addParticle(Particles.BUBBLE, this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ);
}
f1 = 0.8F;
@@ -264,13 +264,13 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
* use {@link #writeUnlessPassenger} or {@link #writeWithoutTypeId} instead.
*/
public void writeAdditional(NBTTagCompound compound) {
compound.setInt("xTile", this.xTile);
compound.setInt("yTile", this.yTile);
compound.setInt("zTile", this.zTile);
compound.setByte("shake", (byte)this.throwableShake);
compound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
compound.putInt("xTile", this.xTile);
compound.putInt("yTile", this.yTile);
compound.putInt("zTile", this.zTile);
compound.putByte("shake", (byte)this.throwableShake);
compound.putByte("inGround", (byte)(this.inGround ? 1 : 0));
if (this.field_200218_h != null) {
compound.setTag("owner", NBTUtil.writeUniqueId(this.field_200218_h));
compound.put("owner", NBTUtil.writeUniqueId(this.field_200218_h));
}
}
@@ -66,7 +66,7 @@ public class EntityVineBall extends EntityThrowable {
public void handleStatusUpdate(byte id) {
if(id == 3) {
for(int j = 0; j < 16; j++) {
world.spawnParticle(new ItemParticleData(Particles.ITEM, new ItemStack(ModItems.vineBall)), posX, posY, posZ, Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1);
world.addParticle(new ItemParticleData(Particles.ITEM, new ItemStack(ModItems.vineBall)), posX, posY, posZ, Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1);
}
}
}
@@ -53,7 +53,7 @@ import javax.annotation.Nullable;
import java.util.List;
public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
public static final String TAG_ACTIVE = "active";
private static final String TAG_ACTIVE = "active";
private static final String TAG_BLOCK_NAME = "blockName";
private static final String TAG_BLOCK_COUNT = "blockCount";
@@ -50,8 +50,8 @@ import java.util.List;
import java.util.Random;
public class ItemBottledMana extends ItemMod {
public static final int SWIGS = 6;
public static final String TAG_SWIGS_LEFT = "swigsLeft";
private static final int SWIGS = 6;
private static final String TAG_SWIGS_LEFT = "swigsLeft";
private static final String TAG_SEED = "randomSeed";
public ItemBottledMana(Properties props) {
@@ -123,14 +123,13 @@ public class ItemBottledMana extends ItemMod {
}
case 9 : { // Highest Possible
int x = MathHelper.floor(living.posX);
MathHelper.floor(living.posY);
int z = MathHelper.floor(living.posZ);
for(int i = 256; i > 0; i--) {
Block block = living.world.getBlockState(new BlockPos(x, i, z)).getBlock();
if(!block.isAir(living.world.getBlockState(new BlockPos(x, i, z)), living.world, new BlockPos(x, i, z))) {
if(living instanceof EntityPlayerMP) {
EntityPlayerMP mp = (EntityPlayerMP) living;
mp.connection.setPlayerLocation(living.posX, i + 1.6, living.posZ, living.rotationYaw, living.rotationPitch);
mp.connection.setPlayerLocation(living.posX, i, living.posZ, living.rotationYaw, living.rotationPitch);
}
break;
}
@@ -11,9 +11,9 @@
package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.block.BlockNote;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityCreeper;
@@ -23,6 +23,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -36,7 +37,6 @@ import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.common.Botania;
@@ -70,7 +70,7 @@ public class ItemCacophonium extends ItemMod {
if(living instanceof EntityCreeper)
sound = SoundEvents.ENTITY_CREEPER_PRIMED;
else if(living instanceof EntitySlime)
sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SMALL_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH;
sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SLIME_SQUISH_SMALL : SoundEvents.ENTITY_SLIME_SQUISH;
else {
try {
sound = (SoundEvent) ReflectionHelper.findMethod(EntityLiving.class, LibObfuscation.GET_LIVING_SOUND[0], LibObfuscation.GET_LIVING_SOUND[1]).invoke(living);
@@ -80,12 +80,8 @@ public class ItemCacophonium extends ItemMod {
}
if(sound != null) {
String s = EntityList.getEntityString(entity);
if(s == null)
s = "generic";
ItemNBTHelper.setString(stack, TAG_SOUND, sound.getRegistryName().toString());
ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name");
ItemNBTHelper.setString(stack, TAG_SOUND_NAME, entity.getType().getTranslationKey());
player.setHeldItem(hand, stack);
if(player.world.isRemote)
@@ -100,11 +96,14 @@ public class ItemCacophonium extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
ItemStack stack = player.getHeldItem(hand);
public EnumActionResult onItemUse(ItemUseContext ctx) {
ItemStack stack = ctx.getItem();
if(getSound(stack) != null) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.NOTEBLOCK) {
if(block instanceof BlockNote) {
world.setBlockState(pos, ModBlocks.cacophonium.getDefaultState());
((TileCacophonium) world.getTileEntity(pos)).stack = stack.copy();
stack.shrink(1);
@@ -121,7 +120,7 @@ public class ItemCacophonium extends ItemMod {
if(isDOIT(stack))
list.add(new TextComponentTranslation("botaniamisc.justDoIt"));
else if(getSound(stack) != null)
list.add(I18n.format(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")));
list.add(new TextComponentTranslation(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")));
}
@Nonnull
@@ -585,6 +585,6 @@ public class ItemCraftingHalo extends ItemMod {
yoff += 12;
}
mc.fontRenderer.drawStringWithShadow(label, mc.mainWindow.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label) / 2, mc.mainWindow.getScaledHeight() / 2 - yoff, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(label, mc.mainWindow.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label.getString()) / 2, mc.mainWindow.getScaledHeight() / 2 - yoff, 0xFFFFFF);
}
}
@@ -47,7 +47,7 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
if(!player.world.isRemote)
player.displayGUIChest(player.getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, player, COST_SELF, true);
player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1F, 1F);
player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 1F, 1F);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
@@ -59,7 +59,7 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
if(!player.world.isRemote)
player.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, player, COST_OTHER, true);
player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1F, 1F);
player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 1F, 1F);
return true;
}
@@ -47,7 +47,7 @@ public class ItemFertilizer extends ItemMod {
for(int k = 2; k >= -2; k--) {
BlockPos pos_ = pos.add(i + 1, k + 1, j + 1);
if(world.isAirBlock(pos_) && (!world.getDimension().isNether() || pos_.getY() < 255)
&& ModBlocks.whiteFlower.isValidPosition(ModBlocks.whiteFlower.getDefaultState(), world, pos_))
&& ModBlocks.whiteFlower.getDefaultState().isValidPosition(world, pos_))
validCoords.add(pos_);
}
}
@@ -13,13 +13,14 @@ package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSkull;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.model.ModelBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemWallOrFloor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.EnumActionResult;
@@ -38,15 +39,15 @@ import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
public class ItemGaiaHead extends ItemMod {
public class ItemGaiaHead extends ItemWallOrFloor {
public ItemGaiaHead() {
super(LibItemNames.GAIA_HEAD);
public ItemGaiaHead(Block floor, Block wall, Properties props) {
super(floor, wall, props);
}
@Override
public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) {
return armorType == EntityEquipmentSlot.HEAD;
public EntityEquipmentSlot getEquipmentSlot(ItemStack stack) {
return EntityEquipmentSlot.HEAD;
}
@OnlyIn(Dist.CLIENT)
@@ -62,81 +63,4 @@ public class ItemGaiaHead extends ItemMod {
super.registerModels();
ForgeHooksClient.registerTESRItemStack(this, 0, TileGaiaHead.class);
}
// Copied from vanila skull itemBlock. Relevant edits are indicated.
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (facing == EnumFacing.DOWN) {
return EnumActionResult.FAIL;
} else {
if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
facing = EnumFacing.UP;
pos = pos.down();
}
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(worldIn, pos);
if (!flag) {
if (!worldIn.getBlockState(pos).getMaterial().isSolid() && !worldIn.isSideSolid(pos, facing, true)) {
return EnumActionResult.FAIL;
}
pos = pos.offset(facing);
}
ItemStack itemstack = playerIn.getHeldItem(hand);
if (playerIn.canPlayerEdit(pos, facing, itemstack) && Blocks.SKULL.canPlaceBlockAt(worldIn, pos)) {
if (worldIn.isRemote) {
return EnumActionResult.SUCCESS;
} else {
worldIn.setBlockState(pos, ModBlocks.gaiaHead.getDefaultState().with(BlockSkull.FACING, facing), 11); // Botania - skull -> gaia head
int i = 0;
if (facing == EnumFacing.UP) {
i = MathHelper.floor(playerIn.rotationYaw * 16.0F / 360.0F + 0.5D) & 15;
}
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntitySkull) {
TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
if (itemstack.getMetadata() == 3) // Botania - do not retrieve skins
{
/*GameProfile gameprofile = null;
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
{
gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
}
}
tileentityskull.setPlayerProfile(gameprofile);*/
} else {
tileentityskull.setType(3); // Botania - Force type to 3 (humanoid)
}
tileentityskull.setSkullRotation(i);
Blocks.SKULL.checkWitherSpawn(worldIn, pos, tileentityskull);
}
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
}
} else {
return EnumActionResult.FAIL;
}
}
}
}
@@ -23,8 +23,10 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
@@ -55,7 +57,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
* Represents a map of dimension IDs to a set of all block swappers
* active in that dimension.
*/
private static final Map<Integer, Set<BlockSwapper>> blockSwappers = new HashMap<>();
private static final Map<DimensionType, Set<BlockSwapper>> blockSwappers = new HashMap<>();
private static final Map<IslandType, float[]> COLORS = ImmutableMap.<IslandType, float[]>builder()
.put(IslandType.GRASS, new float[] {0F, 0.4F, 0F})
.put(IslandType.PODZOL, new float[] {0.5F, 0.37F, 0F})
@@ -118,22 +120,10 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
@SubscribeEvent
public static void onTickEnd(TickEvent.WorldTickEvent event) {
// Block swapper updates should only occur on the server
if(event.world.isRemote)
return;
if(event.phase == Phase.END) {
int dim = event.world.provider.getDimension();
if(event.side == LogicalSide.SERVER && event.phase == Phase.END) {
DimensionType dim = event.world.getDimension().getType();
if(blockSwappers.containsKey(dim)) {
Set<BlockSwapper> swappers = blockSwappers.get(dim);
Iterator<BlockSwapper> iter = swappers.iterator();
while(iter.hasNext()) {
BlockSwapper next = iter.next();
if(next == null || !next.tick())
iter.remove();
}
blockSwappers.get(dim).removeIf(next -> next == null || !next.tick());
}
}
}
@@ -154,13 +144,8 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
private static BlockSwapper addBlockSwapper(World world, BlockPos pos, IslandType type) {
BlockSwapper swapper = new BlockSwapper(world, pos, stateForType(type));
// If a set for the dimension doesn't exist, create it.
int dim = world.provider.getDimension();
if(!blockSwappers.containsKey(dim))
blockSwappers.put(dim, new HashSet<>());
// Add the block swapper
blockSwappers.get(dim).add(swapper);
DimensionType dim = world.getDimension().getType();
blockSwappers.computeIfAbsent(dim, d -> new HashSet<>()).add(swapper);
return swapper;
}
@@ -15,8 +15,6 @@ import net.minecraft.block.BlockFalling;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
@@ -31,7 +29,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
@@ -156,7 +153,7 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
if(inRange(pos_, pos, range, heightscale, pointy)) {
IBlockState state = world.getBlockState(pos_);
Block block = state.getBlock();
if(!block.isAir(state, world, pos_) && !block.isReplaceable(world, pos_) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) {
if(!block.isAir(state, world, pos_) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) {
TileEntity tile = world.getTileEntity(pos_);
if(tile != null) {
@@ -12,17 +12,16 @@ package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -33,7 +32,9 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@@ -75,25 +76,29 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
EntityPlayer player = ctx.getPlayer();
if(player == null)
return EnumActionResult.PASS;
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
if(player.isSneaking()) {
Block block = world.getBlockState(pos).getBlock();
if(block != null) {
if(block instanceof ILexiconable) {
ItemStack stack = player.getHeldItem(hand);
LexiconEntry entry = ((ILexiconable) block).getEntry(world, pos, player, stack);
if(entry != null && isKnowledgeUnlocked(stack, entry.getKnowledgeType())) {
Botania.proxy.setEntryToOpen(entry);
Botania.proxy.setLexiconStack(stack);
if(block instanceof ILexiconable) {
ItemStack stack = ctx.getItem();
LexiconEntry entry = ((ILexiconable) block).getEntry(world, pos, player, stack);
if(entry != null && isKnowledgeUnlocked(stack, entry.getKnowledgeType())) {
Botania.proxy.setEntryToOpen(entry);
Botania.proxy.setLexiconStack(stack);
openBook(player, stack, world, false);
return EnumActionResult.SUCCESS;
}
} else if(world.isRemote) {
RayTraceResult mop = new RayTraceResult(new Vec3d(par8, par9, par10), side, pos);
return Botania.proxy.openWikiPage(world, block, mop) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
openBook(player, stack, world, false);
return EnumActionResult.SUCCESS;
}
} else if(world.isRemote) {
RayTraceResult mop = new RayTraceResult(new Vec3d(ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()), ctx.getFace(), pos);
return Botania.proxy.openWikiPage(world, block, mop) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
}
@@ -101,8 +106,8 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
if(isInCreativeTab(tab)) {
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> list) {
if(isInGroup(tab)) {
list.add(new ItemStack(this));
ItemStack creative = new ItemStack(this);
for(String s : BotaniaAPI.knowledgeTypes.keySet()) {
@@ -115,10 +120,10 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
if(GuiScreen.isShiftKeyDown()) {
String edition = TextFormatting.GOLD + I18n.format("botaniamisc.edition", getEdition());
if(!edition.isEmpty())
ITextComponent edition = new TextComponentTranslation("botaniamisc.edition", getEdition()).applyTextStyle(TextFormatting.GOLD);
if(!edition.getString().isEmpty())
stacks.add(edition);
List<KnowledgeType> typesKnown = new ArrayList<>();
@@ -129,16 +134,12 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
String format = typesKnown.size() == 1 ? "botaniamisc.knowledgeTypesSingular" : "botaniamisc.knowledgeTypesPlural";
addStringToTooltip(I18n.format(format, typesKnown.size()), stacks);
stacks.add(new TextComponentTranslation(format, typesKnown.size()));
for(KnowledgeType type : typesKnown)
addStringToTooltip(" \u2022 " + I18n.format(type.getUnlocalizedName()), stacks);
stacks.add(new TextComponentString(" \u2022 ").appendSibling(new TextComponentTranslation(type.getUnlocalizedName())));
} else addStringToTooltip(I18n.format("botaniamisc.shiftinfo"), stacks);
}
private void addStringToTooltip(String s, List<String> tooltip) {
tooltip.add(s.replaceAll("&", "\u00a7"));
} else stacks.add(new TextComponentTranslation("botaniamisc.shiftinfo"));
}
@OnlyIn(Dist.CLIENT)
@@ -191,7 +192,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int idk, boolean something) {
public void inventoryTick(ItemStack stack, World world, Entity entity, int idk, boolean something) {
int ticks = getQueueTicks(stack);
if(ticks > 0 && entity instanceof EntityPlayer) {
skipSound = ticks < 5;
@@ -231,7 +232,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
for(LexiconEntry entry : BotaniaAPI.getAllEntries())
if(entry.getUnlocalizedName().equals(force))
if(entry != null && ((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType()))
if(((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType()))
return entry;
return null;
@@ -246,9 +247,9 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
public static String getTitle(ItemStack stack) {
String title = ModItems.lexicon.getItemStackDisplayName(ItemStack.EMPTY);
String title = ModItems.lexicon.getDisplayName(ItemStack.EMPTY).getString();
if(!stack.isEmpty())
title = stack.getDisplayName();
title = stack.getDisplayName().getString();
String akashicTomeNBT = "akashictome:displayName";
title = ItemNBTHelper.getString(stack, akashicTomeNBT, title);
@@ -10,7 +10,6 @@
*/
package vazkii.botania.common.item;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
@@ -12,21 +12,22 @@ package vazkii.botania.common.item;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
@@ -47,8 +48,10 @@ import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.entity.EntityManaBurst;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -63,6 +66,8 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
public ItemManaGun(Properties props) {
super(props.defaultMaxDamage(COOLDOWN));
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "clip"), (stack, world, entity) -> hasClip(stack) ? 1 : 0);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "desu"), (stack, world, entity) -> isSugoiKawaiiDesuNe(stack) ? 1 : 0);
}
@Nonnull
@@ -150,7 +155,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
return props;
}
public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request, EnumHand hand) {
private EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request, EnumHand hand) {
EntityManaBurst burst = new EntityManaBurst(player, hand);
BurstProperties props = getBurstProps(player, stack, request, hand);
@@ -210,9 +215,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
ITextComponent cmp = super.getDisplayName(stack);
if (!lens.isEmpty()) {
cmp.appendText(" (");
ITextComponent lensName = lens.getDisplayName();
lensName.getStyle().setColor(TextFormatting.GREEN);
cmp.appendSibling(lensName);
cmp.appendSibling(lens.getDisplayName().applyTextStyle(TextFormatting.GREEN));
cmp.appendText(")");
}
return cmp;
@@ -310,23 +313,4 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
public boolean usesMana(ItemStack stack) {
return true;
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelBakery.registerItemVariants(this,
new ModelResourceLocation("botania:desuGunClip", "inventory"),
new ModelResourceLocation("botania:desuGun", "inventory"),
new ModelResourceLocation("botania:manaGunClip", "inventory"),
new ModelResourceLocation("botania:manaGun", "inventory"));
ModelLoader.setCustomMeshDefinition(this, stack -> {
if (hasClip(stack) && isSugoiKawaiiDesuNe(stack))
return new ModelResourceLocation("botania:desuGunClip", "inventory");
else if (isSugoiKawaiiDesuNe(stack))
return new ModelResourceLocation("botania:desuGun", "inventory");
else if(hasClip(stack))
return new ModelResourceLocation("botania:manaGunClip", "inventory");
else return new ModelResourceLocation("botania:manaGun", "inventory");
});
}
}
@@ -10,22 +10,23 @@
*/
package vazkii.botania.common.item;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.IBucketPickupHandler;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.fluid.Fluid;
import net.minecraft.init.Fluids;
import net.minecraft.init.Particles;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.IFluidBlock;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
@@ -35,42 +36,45 @@ public class ItemOpenBucket extends ItemMod {
super(props);
}
// [VanillaCopy] ItemBucket, only the empty cases
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
RayTraceResult rtr = rayTrace(world, player, true);
ItemStack stack = player.getHeldItem(hand);
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
if(rtr == null)
return ActionResult.newResult(EnumActionResult.PASS, stack);
else {
if(rtr.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK) {
BlockPos pos = rtr.getBlockPos();
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemstack, raytraceresult);
if (ret != null) return ret;
if(!world.isBlockModifiable(player, pos))
return ActionResult.newResult(EnumActionResult.PASS, stack);
if (raytraceresult == null) {
return new ActionResult<>(EnumActionResult.PASS, itemstack);
} else if (raytraceresult.type == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = raytraceresult.getBlockPos();
if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, raytraceresult.sideHit, itemstack)) {
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() instanceof IBucketPickupHandler) {
Fluid fluid = ((IBucketPickupHandler)iblockstate1.getBlock()).pickupFluid(worldIn, blockpos, iblockstate1);
if (fluid != Fluids.EMPTY) {
playerIn.addStat(StatList.ITEM_USED.get(this));
playerIn.playSound(fluid.isIn(FluidTags.LAVA) ? SoundEvents.ITEM_BUCKET_FILL_LAVA : SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
if(!player.canPlayerEdit(pos, rtr.sideHit, stack))
return ActionResult.newResult(EnumActionResult.PASS, stack);
// Botania: some particles
for(int x = 0; x < 5; x++)
worldIn.addParticle(Particles.POOF, blockpos.getX() + Math.random(), blockpos.getY() + Math.random(), blockpos.getZ() + Math.random(), 0, 0, 0);
IBlockState state = world.getBlockState(pos);
Fluid fluid = FluidRegistry.lookupFluidForBlock(state.getBlock());
boolean isFull = state.getBlock() instanceof BlockLiquid && state.get(BlockLiquid.LEVEL) == 0
|| state.getBlock() instanceof IFluidBlock && Math.abs(((IFluidBlock) state.getBlock()).getFilledPercentage(world, pos)) >= 1;
if(fluid != null && isFull) {
player.playSound(fluid.getFillSound(world, pos), 1.0f, 1.0f);
world.setBlockToAir(pos);
for(int x = 0; x < 5; x++)
world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
}
}
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
return new ActionResult<>(EnumActionResult.FAIL, itemstack);
} else {
return new ActionResult<>(EnumActionResult.FAIL, itemstack);
}
} else {
return new ActionResult<>(EnumActionResult.PASS, itemstack);
}
}
}
@@ -51,7 +51,7 @@ public class ItemPinkinator extends ItemMod {
int range = 16;
List<EntityWither> withers = world.getEntitiesWithinAABB(EntityWither.class, new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range));
for(EntityWither wither : withers)
if(!world.isRemote && !wither.removed && !(wither instanceof EntityPinkWither)) {
if(!world.isRemote && wither.isAlive() && !(wither instanceof EntityPinkWither)) {
wither.remove();
EntityPinkWither pink = new EntityPinkWither(world);
pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch);
@@ -11,11 +11,14 @@
package vazkii.botania.common.item;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.state.properties.RailShape;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -32,28 +35,35 @@ public class ItemPoolMinecart extends ItemMod {
super(builder);
}
// [VanillaCopy] ItemMinecart
@Nonnull
@Override
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
ItemStack stack = ctx.getItem();
public EnumActionResult onItemUse(ItemUseContext context) {
World world = context.getWorld();
BlockPos blockpos = context.getPos();
IBlockState iblockstate = world.getBlockState(blockpos);
if (!iblockstate.isIn(BlockTags.RAILS)) {
return EnumActionResult.FAIL;
} else {
ItemStack itemstack = context.getItem();
if (!world.isRemote) {
RailShape railshape = iblockstate.getBlock() instanceof BlockRailBase ? ((BlockRailBase)iblockstate.getBlock()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH;
double d0 = 0.0D;
if (railshape.isAscending()) {
d0 = 0.5D;
}
if(BlockRailBase.isRail(world.getBlockState(pos))) {
if(!world.isRemote) {
EntityMinecart entityminecart = new EntityPoolMinecart(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
if(stack.hasDisplayName())
entityminecart.setCustomName(stack.getDisplayName());
EntityMinecart entityminecart = new EntityPoolMinecart(world, blockpos.getX() + 0.5D, blockpos.getY() + 0.0625D + d0, blockpos.getZ() + 0.5D);
if (itemstack.hasDisplayName()) {
entityminecart.setCustomName(itemstack.getDisplayName());
}
world.spawnEntity(entityminecart);
}
stack.shrink(1);
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
}
@@ -124,7 +124,7 @@ public class ItemSextant extends ItemMod {
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
public static double calculateRadius(ItemStack stack, EntityPlayer player) {
private static double calculateRadius(ItemStack stack, EntityPlayer player) {
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
@@ -14,12 +14,13 @@ import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
@@ -41,6 +42,7 @@ import vazkii.botania.common.advancements.UseItemSuccessTrigger;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public class ItemSpawnerMover extends ItemMod {
@@ -54,7 +56,8 @@ public class ItemSpawnerMover extends ItemMod {
addPropertyOverride(new ResourceLocation("botania", "full"), (stack, worldIn, entityIn) -> hasData(stack) ? 1 : 0);
}
public static NBTTagCompound getSpawnerTag(ItemStack stack) {
@Nullable
private static NBTTagCompound getSpawnerTag(ItemStack stack) {
NBTTagCompound tag = stack.getTag();
if(tag != null && tag.contains(TAG_SPAWNER)) {
return tag.getCompound(TAG_SPAWNER);
@@ -63,6 +66,7 @@ public class ItemSpawnerMover extends ItemMod {
return null;
}
@Nullable
private static ResourceLocation getEntityId(ItemStack stack) {
NBTTagCompound tag = getSpawnerTag(stack);
if(tag != null && tag.contains(TAG_SPAWN_DATA)) {
@@ -75,7 +79,7 @@ public class ItemSpawnerMover extends ItemMod {
return null;
}
public static boolean hasData(ItemStack stack) {
private static boolean hasData(ItemStack stack) {
return getEntityId(stack) != null;
}
@@ -84,7 +88,7 @@ public class ItemSpawnerMover extends ItemMod {
public void addInformation(ItemStack stack, World world, List<ITextComponent> infoList, ITooltipFlag flags) {
ResourceLocation id = getEntityId(stack);
if (id != null) {
EntityType<?> type = ForgeRegistries.ENTITIES.getValue();
EntityType<?> type = ForgeRegistries.ENTITIES.getValue(id);
if (type != null) {
infoList.add(type.func_212546_e());
}
@@ -93,84 +97,75 @@ public class ItemSpawnerMover extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
ItemStack itemstack = player.getHeldItem(hand);
if(getEntityId(itemstack) == null) {
if(world.getBlockState(pos).getBlock() == Blocks.SPAWNER) {
if(!world.isRemote) {
TileEntity te = world.getTileEntity(pos);
NBTTagCompound tag = new NBTTagCompound();
tag.put(TAG_SPAWNER, te.write(new NBTTagCompound()));
player.getCooldownTracker().setCooldown(this, 20);
itemstack.setTag(tag);
world.destroyBlock(pos, false);
UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, itemstack, (WorldServer) world, pos.getX(), pos.getY(), pos.getZ());
player.renderBrokenItemStack(itemstack);
} else {
for(int i = 0; i < 50; i++) {
float red = (float) Math.random();
float green = (float) Math.random();
float blue = (float) Math.random();
Botania.proxy.wispFX(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, red, green, blue, (float) Math.random() * 0.1F + 0.05F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F);
}
}
return EnumActionResult.SUCCESS;
} else return EnumActionResult.PASS;
public EnumActionResult onItemUse(ItemUseContext ctx) {
if(getEntityId(ctx.getItem()) == null) {
return captureSpawner(ctx) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
} else {
return placeBlock(itemstack, player, world, pos, side, xOffset, yOffset, zOffset) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
return placeSpawner(ctx);
}
}
// Adapted from ItemBlock.onItemUse
private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xOffset, float yOffset, float zOffset) {
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
private EnumActionResult placeSpawner(ItemUseContext ctx) {
ItemStack spawner = new ItemStack(Blocks.SPAWNER);
ItemUseContext placeCtx = new BlockItemUseContext(ctx.getWorld(), ctx.getPlayer(), spawner, ctx.getPos(), ctx.getFace(), ctx.getHitX(), ctx.getHitY(), ctx.getHitZ());
EnumActionResult res = spawner.onItemUse(placeCtx);
if(!block.isReplaceable(world, pos)) {
pos = pos.offset(side);
}
if(res == EnumActionResult.SUCCESS) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
ItemStack mover = ctx.getItem();
if(itemstack.isEmpty()) {
return false;
} else if(!player.canPlayerEdit(pos, side, itemstack)) {
return false;
} else if(world.mayPlace(Blocks.MOB_SPAWNER, pos, false, side, null)) {
int meta = this.getMetadata(itemstack.getMetadata());
IBlockState iblockstate1 = Blocks.MOB_SPAWNER.getStateForPlacement(world, pos, side, xOffset, yOffset, zOffset, meta, player);
if(!world.isRemote) {
TileEntity te = world.getTileEntity(pos);
NBTTagCompound tag = mover.getTag();
if (te instanceof TileEntityMobSpawner && tag.contains(TAG_SPAWNER)) {
tag = tag.getCompound(TAG_SPAWNER);
tag.putInt("x", pos.getX());
tag.putInt("y", pos.getY());
tag.putInt("z", pos.getZ());
te.read(tag);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
}
if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) {
world.playSound(null, pos, Blocks.MOB_SPAWNER.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (Blocks.MOB_SPAWNER.getSoundType().getVolume() + 1.0F) / 2.0F, Blocks.MOB_SPAWNER.getSoundType().getPitch() * 0.8F);
player.renderBrokenItemStack(itemstack);
itemstack.shrink(1);
if(ctx.getPlayer() != null)
ctx.getPlayer().renderBrokenItemStack(mover);
mover.shrink(1);
} else {
for(int i = 0; i < 100; i++)
Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6);
}
return true;
} else {
return false;
}
return res;
}
// Adapted from ItemBlock.placeBlockAt
private boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState state) {
if (!world.setBlockState(pos, state, 3))
return false;
private boolean captureSpawner(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
ItemStack stack = ctx.getItem();
EntityPlayer player = ctx.getPlayer();
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.SPAWNER) {
TileEntity te = world.getTileEntity(pos);
NBTTagCompound tag = stack.getTag();
if (te instanceof TileEntityMobSpawner && tag.contains(TAG_SPAWNER)) {
tag = tag.getCompound(TAG_SPAWNER);
tag.putInt("x", pos.getX());
tag.putInt("y", pos.getY());
tag.putInt("z", pos.getZ());
te.read(tag);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
if(world.getBlockState(pos).getBlock() == Blocks.SPAWNER) {
if(!world.isRemote) {
TileEntity te = world.getTileEntity(pos);
NBTTagCompound tag = new NBTTagCompound();
tag.put(TAG_SPAWNER, te.write(new NBTTagCompound()));
stack.setTag(tag);
world.destroyBlock(pos, false);
if(player != null) {
player.getCooldownTracker().setCooldown(this, 20);
UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, stack, (WorldServer) world, pos.getX(), pos.getY(), pos.getZ());
player.renderBrokenItemStack(stack);
}
} else {
for(int i = 0; i < 50; i++) {
float red = (float) Math.random();
float green = (float) Math.random();
float blue = (float) Math.random();
Botania.proxy.wispFX(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, red, green, blue, (float) Math.random() * 0.1F + 0.05F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F);
}
}
}
return true;
return true;
} else return false;
}
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCommandBlock;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
@@ -22,6 +23,7 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
@@ -29,6 +31,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
@@ -79,12 +82,21 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
Block block = world.getBlockState(pos).getBlock();
public EnumActionResult onItemUse(ItemUseContext ctx) {
ItemStack stack = ctx.getItem();
World world = ctx.getWorld();
EntityPlayer player = ctx.getPlayer();
BlockPos pos = ctx.getPos();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
EnumFacing side = ctx.getFace();
BlockPos boundPos = getBoundTile(stack);
TileEntity boundTile = world.getTileEntity(boundPos);
if(player == null)
return EnumActionResult.PASS;
if(player.isSneaking()) {
// Try to complete a binding
if(boundPos.getY() != -1 && !pos.equals(boundPos)) {
@@ -105,10 +117,12 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
}
if(player.canPlayerEdit(pos, side, stack)
&& (!(block instanceof BlockCommandBlock) || player.canUseCommandBlock())
&& block.rotateBlock(world, pos, side)) {
player.swingArm(hand);
return EnumActionResult.SUCCESS;
&& (!(block instanceof BlockCommandBlock) || player.canUseCommandBlock())) {
IBlockState newState = state.rotate(world, pos, Rotation.CLOCKWISE_90);
if(newState != state) {
world.setBlockState(pos, newState);
return EnumActionResult.SUCCESS;
}
}
}
@@ -157,15 +171,12 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
else setBoundTile(stack, pos);
if(world.isRemote) {
player.swingArm(hand);
player.playSound(ModSounds.ding, 0.11F, 1F);
}
wanded = true;
} else {
wanded = ((IWandable) block).onUsedByWand(player, stack, world, pos, side);
if(wanded && world.isRemote)
player.swingArm(hand);
}
return wanded ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
@@ -173,7 +184,7 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
if(!world.isRemote && ((BlockPistonRelay) ModBlocks.pistonRelay).playerPositions.containsKey(player.getUniqueID())) {
BlockPistonRelay.DimWithPos bindPos = ((BlockPistonRelay) ModBlocks.pistonRelay).playerPositions.get(player.getUniqueID());
BlockPistonRelay.DimWithPos currentPos = new BlockPistonRelay.DimWithPos(world.getDimension().getId(), pos);
BlockPistonRelay.DimWithPos currentPos = new BlockPistonRelay.DimWithPos(world.getDimension().getType(), pos);
((BlockPistonRelay) ModBlocks.pistonRelay).playerPositions.remove(player.getUniqueID());
((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.put(bindPos, currentPos);
@@ -240,7 +240,7 @@ public final class ModItems {
public static final Item miningRing = new ItemMiningRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MINING_RING);
public static final Item terraPick = new ItemTerraPick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRA_PICK);
public static final Item divaCharm = new ItemDivaCharm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.DIVA_CHARM);
public static final Item flightTiara = new ItemFlightTiara();
public static final Item flightTiara = new ItemFlightTiara(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FLIGHT_TIARA);
public static final Item enderDagger = new ItemEnderDagger(unstackable().defaultMaxDamage(69).setNoRepair()); // What you looking at?
public static final Item darkQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[0]);
public static final Item manaQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[1]);
@@ -1,20 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Mar 31, 2015, 9:00:38 PM (GMT)]
*/
package vazkii.botania.common.item.block;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public interface IRarityBlock {
public EnumRarity getRarity(ItemStack stack);
}
@@ -12,7 +12,8 @@ package vazkii.botania.common.item.block;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import javax.annotation.Nonnull;
@@ -24,9 +25,9 @@ public class ItemBlockFloatingSpecialFlower extends ItemBlockSpecialFlower {
@Nonnull
@Override
public String getItemStackDisplayName(@Nonnull ItemStack stack) {
String flowerName = getTranslationKey(stack) + ".name";
return String.format(I18n.translateToLocal("botaniamisc.floatingPrefix"), I18n.translateToLocal(flowerName));
public ITextComponent getDisplayName(@Nonnull ItemStack stack) {
String flowerName = getTranslationKey(stack);
return new TextComponentTranslation("botaniamisc.floatingPrefix").appendSibling(new TextComponentTranslation(flowerName));
}
}
@@ -57,8 +57,8 @@ import java.util.List;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyProvider {
public ItemBlockSpecialFlower(Block block1) {
super(block1);
public ItemBlockSpecialFlower(Block block1, Properties props) {
super(block1, props);
}
@Override
@@ -1,37 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jan 16, 2014, 5:54:06 PM (GMT)]
*/
package vazkii.botania.common.item.block;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class ItemBlockWithMetadataAndName extends ItemBlockMod {
public ItemBlockWithMetadataAndName(Block block) {
super(block);
setHasSubtypes(true);
}
@Nonnull
@Override
public String getTranslationKey(ItemStack stack) {
return super.getTranslationKey(stack) + stack.getItemDamage();
}
@Override
public int getMetadata(int damage)
{
return damage;
}
}
@@ -21,14 +21,20 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionUtil;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.brew.IBrewItem;
@@ -119,17 +125,27 @@ public class ItemBrewBase extends ItemMod implements IBrewItem {
@Nonnull
@Override
public String getItemStackDisplayName(@Nonnull ItemStack stack) {
return String.format(net.minecraft.util.text.translation.I18n.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name"), net.minecraft.util.text.translation.I18n.translateToLocal(getBrew(stack).getUnlocalizedName(stack)), TextFormatting.BOLD + "" + getSwigsLeft(stack) + TextFormatting.RESET);
public ITextComponent getDisplayName(@Nonnull ItemStack stack) {
ITextComponent cmp = new TextComponentTranslation(getTranslationKey(), new TextComponentTranslation(getBrew(stack).getUnlocalizedName(stack)));
cmp.appendSibling(new TextComponentString(Integer.toString(getSwigsLeft(stack))).applyTextStyle(TextFormatting.BOLD));
return cmp;
}
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flags) {
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
Brew brew = getBrew(stack);
for(PotionEffect effect : brew.getPotionEffects(stack)) {
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
list.add(format + I18n.format(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.format("botania.roman" + (effect.getAmplifier() + 1))) + TextFormatting.GRAY + (effect.getPotion().isInstant() ? "" : " (" + Potion.getPotionDurationString(effect, 1F) + ")"));
ITextComponent cmp = new TextComponentTranslation(effect.getEffectName());
if(effect.getAmplifier() > 0) {
cmp.appendText(" ");
cmp.appendSibling(new TextComponentTranslation("botania.roman" + (effect.getAmplifier() + 1)));
}
if(!effect.getPotion().isInstant()) {
cmp.appendText(" (" + PotionUtil.getPotionDurationString(effect, 1) + ")").applyTextStyle(TextFormatting.GRAY);
}
list.add(cmp.applyTextStyle(format));
}
}
@@ -17,8 +17,11 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionUtil;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -60,22 +63,26 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
Brew brew = getBrew(stack);
if(brew == BotaniaAPI.fallbackBrew) {
addStringToTooltip(TextFormatting.LIGHT_PURPLE + I18n.format("botaniamisc.notInfused"), list);
list.add(new TextComponentTranslation("botaniamisc.notInfused").applyTextStyle(TextFormatting.LIGHT_PURPLE));
return;
}
addStringToTooltip(TextFormatting.LIGHT_PURPLE + I18n.format("botaniamisc.brewOf", I18n.format(brew.getUnlocalizedName(stack))), list);
list.add(new TextComponentTranslation("botaniamisc.brewOf", new TextComponentTranslation(brew.getUnlocalizedName(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE));
for(PotionEffect effect : brew.getPotionEffects(stack)) {
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
PotionEffect longEffect = new PotionEffect(effect.getPotion(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false, true);
addStringToTooltip(" " + format + I18n.format(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.format("botania.roman" + (effect.getAmplifier() + 1))) + TextFormatting.GRAY + (effect.getPotion().isInstant() ? "" : " (" + Potion.getPotionDurationString(longEffect, 1F) + ")"), list);
ITextComponent cmp = new TextComponentTranslation(effect.getEffectName());
if(effect.getAmplifier() > 0) {
cmp.appendText(" ");
cmp.appendSibling(new TextComponentTranslation("botania.roman" + (effect.getAmplifier() + 1)));
}
if(!effect.getPotion().isInstant()) {
cmp.appendSibling(new TextComponentString(" (" + PotionUtil.getPotionDurationString(longEffect, 1) + ")").applyTextStyle(TextFormatting.GRAY));
}
list.add(cmp.applyTextStyle(format));
}
}
void addStringToTooltip(String s, List<String> tooltip) {
tooltip.add(s.replaceAll("&", "\u00a7"));
}
@Override
public Brew getBrew(ItemStack stack) {
String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, "");
@@ -75,11 +75,11 @@ public class ItemManasteelArmor extends ItemArmor implements IManaUsingItem, IPh
@Override
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(player instanceof EntityPlayer)
onArmorTick(world, (EntityPlayer) player, stack);
onArmorTick(stack, world, (EntityPlayer) player);
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
public void onArmorTick(ItemStack stack, World world, EntityPlayer player) {
if(!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@@ -44,7 +44,7 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscou
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
public void onArmorTick(ItemStack stack, World world, EntityPlayer player) {
if(!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@@ -52,8 +52,8 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
super.onArmorTick(world, player, stack);
public void onArmorTick(ItemStack stack, World world, EntityPlayer player) {
super.onArmorTick(stack, world, player);
if(hasArmorSet(player)) {
int food = player.getFoodStats().getFoodLevel();
if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0)
@@ -27,6 +27,8 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -69,19 +71,24 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
@OnlyIn(Dist.CLIENT)
@Override
public void addHiddenTooltip(ItemStack stack, World world, List<String> list, ITooltipFlag adv) {
public void addHiddenTooltip(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag adv) {
super.addHiddenTooltip(stack, world, list, adv);
Brew brew = getBrew(stack);
if(brew == BotaniaAPI.fallbackBrew) {
addStringToTooltip(TextFormatting.LIGHT_PURPLE + I18n.format("botaniamisc.notInfused"), list);
list.add(new TextComponentTranslation("botaniamisc.notInfused").applyTextStyle(TextFormatting.LIGHT_PURPLE));
return;
}
addStringToTooltip(TextFormatting.LIGHT_PURPLE + I18n.format("botaniamisc.brewOf", I18n.format(brew.getUnlocalizedName(stack))), list);
list.add(new TextComponentTranslation("botaniamisc.brewOf", I18n.format(brew.getUnlocalizedName(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE));
for(PotionEffect effect : brew.getPotionEffects(stack)) {
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
addStringToTooltip(" " + format + I18n.format(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.format("botania.roman" + (effect.getAmplifier() + 1))), list);
ITextComponent cmp = new TextComponentTranslation(effect.getEffectName());
if(effect.getAmplifier() > 0) {
cmp.appendText(" ");
cmp.appendSibling(new TextComponentTranslation("botania.roman" + (effect.getAmplifier() + 1)));
}
list.add(cmp.applyTextStyle(format));
}
}
@@ -15,7 +15,6 @@ import baubles.api.BaublesApi;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
@@ -24,18 +23,21 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -68,13 +70,14 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
private static final ResourceLocation textureHud = new ResourceLocation(LibResources.GUI_HUD_ICONS);
private static final ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO);
private static final String TAG_VARIANT = "variant";
private static final String TAG_FLYING = "flying";
private static final String TAG_TIME_LEFT = "timeLeft";
private static final String TAG_INFINITE_FLIGHT = "infiniteFlight";
private static final String TAG_DASH_COOLDOWN = "dashCooldown";
private static final String TAG_IS_SPRINTING = "isSprinting";
public static final List<String> playersWithFlight = new ArrayList();
private static final List<String> playersWithFlight = new ArrayList<>();
private static final int COST = 35;
private static final int COST_OVERKILL = COST * 3;
private static final int MAX_FLY_TIME = 1200;
@@ -82,12 +85,11 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
private static final int SUBTYPES = 8;
public static final int WING_TYPES = 9;
public static final String SUPER_AWESOME_HASH = "4D0F274C5E3001C95640B5E88A821422C8B1E132264492C043A3D746B705C025";
private static final String SUPER_AWESOME_HASH = "4D0F274C5E3001C95640B5E88A821422C8B1E132264492C043A3D746B705C025";
public ItemFlightTiara() {
super(LibItemNames.FLIGHT_TIARA);
public ItemFlightTiara(Properties props) {
super(props);
MinecraftForge.EVENT_BUS.register(this);
setHasSubtypes(true);
}
@Override
@@ -96,26 +98,29 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
if(isInCreativeTab(tab)) {
for(int i = 0; i < SUBTYPES + 1; i++)
list.add(new ItemStack(this, 1, i));
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> list) {
if(isInGroup(tab)) {
for(int i = 0; i < SUBTYPES + 1; i++) {
ItemStack stack = new ItemStack(this);
ItemNBTHelper.setInt(stack, TAG_VARIANT, i);
}
}
}
@OnlyIn(Dist.CLIENT)
@Override
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
super.addHiddenTooltip(par1ItemStack, world, stacks, flags);
stacks.add(I18n.format("botania.wings" + par1ItemStack.getItemDamage()));
public void addHiddenTooltip(ItemStack stack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
super.addHiddenTooltip(stack, world, stacks, flags);
stacks.add(new TextComponentTranslation("botania.wings" + ItemNBTHelper.getInt(stack, TAG_VARIANT, 0)));
}
@Override
public void onEquipped(ItemStack stack, EntityLivingBase player) {
super.onEquipped(stack, player);
if(stack.getItemDamage() != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName(), SUPER_AWESOME_HASH)) {
stack.setItemDamage(WING_TYPES);
stack.getTagCompound().removeTag("display");
int variant = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0);
if(variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) {
ItemNBTHelper.setInt(stack, TAG_VARIANT, WING_TYPES);
stack.clearCustomName();
}
}
@@ -126,7 +131,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
if(player instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) player;
boolean flying = p.capabilities.isFlying;
boolean flying = p.abilities.isFlying;
boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false);
boolean isSprinting = p.isSprinting();
@@ -185,8 +190,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
if(playersWithFlight.contains(playerStr(player))) {
if(shouldPlayerHaveFlight(player)) {
player.capabilities.allowFlying = true;
if(player.capabilities.isFlying) {
player.abilities.allowFlying = true;
if(player.abilities.isFlying) {
if(!player.world.isRemote)
ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true);
else if(Math.abs(player.motionX) > 0.1 || Math.abs(player.motionZ) > 0.1) {
@@ -199,7 +204,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
float g = 1F;
float b = 1F;
switch(tiara.getItemDamage()) {
int variant = ItemNBTHelper.getInt(tiara, TAG_VARIANT, 0);
switch(variant) {
case 2 : {
r = 0.1F;
g = 0.1F;
@@ -252,23 +258,23 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
}
}
} else {
if(!player.isSpectator() && !player.capabilities.isCreativeMode) {
player.capabilities.allowFlying = false;
player.capabilities.isFlying = false;
player.capabilities.disableDamage = false;
if(!player.isSpectator() && !player.abilities.isCreativeMode) {
player.abilities.allowFlying = false;
player.abilities.isFlying = false;
player.abilities.disableDamage = false;
}
playersWithFlight.remove(playerStr(player));
}
} else if(shouldPlayerHaveFlight(player)) {
playersWithFlight.add(playerStr(player));
player.capabilities.allowFlying = true;
player.abilities.allowFlying = true;
}
}
}
@SubscribeEvent
public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
String username = event.player.getGameProfile().getName();
String username = event.getPlayer().getGameProfile().getName();
playersWithFlight.remove(username + ":false");
playersWithFlight.remove(username + ":true");
}
@@ -300,13 +306,13 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
int meta = stack.getItemDamage();
int meta = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0);
if(type == RenderType.BODY) {
if(meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) {
TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.tiaraWingIcons[meta - 1];
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
boolean flying = player.capabilities.isFlying;
boolean flying = player.abilities.isFlying;
float rz = 120F;
float rx = 20F + (float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F));
@@ -318,7 +324,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.color4f(1F, 1F, 1F, 1F);
int light = 15728880;
int lightmapX = light % 65536;
@@ -369,7 +375,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
rz = 0F;
ry = -rx;
rx = 0F;
GlStateManager.color(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F);
GlStateManager.color4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F);
break;
}
case 8 : { // Mega Ultra Chicken
@@ -382,7 +388,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
rx = 0F;
h = 1.1F;
ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * 0.2F) + 0.6F) * (flying ? 12F : 5F));
GlStateManager.color(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F));
GlStateManager.color4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F));
}
}
@@ -398,32 +404,32 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
Helper.rotateIfSneaking(player);
GlStateManager.translate(0F, h, i);
GlStateManager.translatef(0F, h, i);
GlStateManager.rotate(rz, 0F, 0F, 1F);
GlStateManager.rotate(rx, 1F, 0F, 0F);
GlStateManager.rotate(ry, 0F, 1F, 0F);
GlStateManager.scale(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F);
GlStateManager.scale(sr, sr, sr);
GlStateManager.rotate(-ry, 0F, 1F, 0F);
GlStateManager.rotate(-rx, 1F, 0F, 0F);
GlStateManager.rotate(-rz, 0F, 0F, 1F);
GlStateManager.rotatef(rz, 0F, 0F, 1F);
GlStateManager.rotatef(rx, 1F, 0F, 0F);
GlStateManager.rotatef(ry, 0F, 1F, 0F);
GlStateManager.scalef(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
GlStateManager.scalef(sr, sr, sr);
GlStateManager.rotatef(-ry, 0F, 1F, 0F);
GlStateManager.rotatef(-rx, 1F, 0F, 0F);
GlStateManager.rotatef(-rz, 0F, 0F, 1F);
if(meta != 2) { // Sephiroth
GlStateManager.scale(-1F, 1F, 1F);
GlStateManager.rotate(rz, 0F, 0F, 1F);
GlStateManager.rotate(rx, 1F, 0F, 0F);
GlStateManager.rotate(ry, 0F, 1F, 0F);
GlStateManager.scale(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F);
GlStateManager.scale(sr, sr, sr);
GlStateManager.rotate(-ry, 1F, 0F, 0F);
GlStateManager.rotate(-rx, 1F, 0F, 0F);
GlStateManager.rotate(-rz, 0F, 0F, 1F);
GlStateManager.scalef(-1F, 1F, 1F);
GlStateManager.rotatef(rz, 0F, 0F, 1F);
GlStateManager.rotatef(rx, 1F, 0F, 0F);
GlStateManager.rotatef(ry, 0F, 1F, 0F);
GlStateManager.scalef(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
GlStateManager.scalef(sr, sr, sr);
GlStateManager.rotatef(-ry, 1F, 0F, 0F);
GlStateManager.rotatef(-rx, 1F, 0F, 0F);
GlStateManager.rotatef(-rz, 0F, 0F, 1F);
}
GlStateManager.color(1F, 1F, 1F);
GlStateManager.color3f(1F, 1F, 1F);
GlStateManager.popMatrix();
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lbx, lby);
@@ -440,18 +446,18 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, 240, 240);
GlStateManager.disableLighting();
GlStateManager.disableCull();
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.color4f(1F, 1F, 1F, 1F);
Minecraft.getInstance().textureManager.bindTexture(textureHalo);
if(player != null)
Helper.translateToHeadLevel(player);
GlStateManager.translate(0, 1.5F, 0);
GlStateManager.rotate(30, 1, 0, -1);
GlStateManager.translate(-0.1F, -0.5F, -0.1F);
GlStateManager.translatef(0, 1.5F, 0);
GlStateManager.rotatef(30, 1, 0, -1);
GlStateManager.translatef(-0.1F, -0.5F, -0.1F);
if(player != null)
GlStateManager.rotate(player.ticksExisted + partialTicks, 0, 1, 0);
else GlStateManager.rotate(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0);
GlStateManager.rotatef(player.ticksExisted + partialTicks, 0, 1, 0);
else GlStateManager.rotatef(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0);
Tessellator tes = Tessellator.getInstance();
ShaderHelper.useShader(ShaderHelper.halo);
@@ -470,7 +476,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
@OnlyIn(Dist.CLIENT)
public static void renderHUD(EntityPlayer player, ItemStack stack) {
int u = Math.max(1, stack.getItemDamage()) * 9 - 9;
int u = Math.max(1, ItemNBTHelper.getInt(stack, TAG_VARIANT, 0)) * 9 - 9;
int v = 0;
Minecraft mc = Minecraft.getInstance();
@@ -478,7 +484,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
int xo = mc.mainWindow.getScaledWidth() / 2 + 10;
int x = xo;
int y = mc.mainWindow.getScaledHeight() - ConfigHandler.flightBarHeight;
if(player.isInsideOfMaterial(Material.WATER))
if(player.areEyesInFluid(FluidTags.WATER))
y = mc.mainWindow.getScaledHeight() - ConfigHandler.flightBarBreathHeight;
int left = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME);
@@ -53,7 +53,7 @@ public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translatef(-0.5, -0.90, armor ? -0.4 : -0.25);
GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem;
float f = gemIcon.getMinU();
@@ -113,7 +113,7 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), width);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), width);
GlStateManager.popMatrix();
}
}
@@ -46,7 +46,7 @@ public class ItemStarSword extends ItemManasteelSword {
if(player.getHeldItemMainhand() == par1ItemStack && player.swingProgress == check && !world.isRemote) {
RayTraceResult pos = ToolCommons.raytraceFromEntity(world, par3Entity, true, 48);
if(pos != null && pos.getBlockPos() != null) {
if(pos != null && pos.type == RayTraceResult.Type.BLOCK) {
Vector3 posVec = Vector3.fromBlockPos(pos.getBlockPos());
Vector3 motVec = new Vector3((0.5 * Math.random() - 0.25) * 18, 24, (0.5 * Math.random() - 0.25) * 18);
posVec = posVec.add(motVec);
@@ -21,6 +21,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
@@ -75,7 +76,7 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
* Represents a map of dimension IDs to a set of all block swappers
* active in that dimension.
*/
private static final Map<Integer, Set<BlockSwapper>> blockSwappers = new HashMap<>();
private static final Map<DimensionType, Set<BlockSwapper>> blockSwappers = new HashMap<>();
public ItemTerraAxe(Properties props) {
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
@@ -126,20 +127,13 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
return;
if(event.phase == Phase.END) {
int dim = event.world.provider.getDimension();
DimensionType dim = event.world.getDimension().getType();
if(blockSwappers.containsKey(dim)) {
Set<BlockSwapper> swappers = blockSwappers.get(dim);
// Iterate through all of our swappers, removing any
// which no longer need to tick.
Iterator<BlockSwapper> swapper = swappers.iterator();
while(swapper.hasNext()) {
BlockSwapper next = swapper.next();
// If a null sneaks in or the swapper is done, remove it
if(next == null || !next.tick())
swapper.remove();
}
swappers.removeIf(next -> next == null || !next.tick());
}
}
}
@@ -165,13 +159,8 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
if(world.isRemote)
return;
// If the mapping for this dimension doesn't exist, create it.
int dim = world.provider.getDimension();
if(!blockSwappers.containsKey(dim))
blockSwappers.put(dim, new HashSet<>());
// Add the swapper
blockSwappers.get(dim).add(swapper);
DimensionType dim = world.getDimension().getType();
blockSwappers.computeIfAbsent(dim, d -> new HashSet<>()).add(swapper);
}
/**
@@ -22,9 +22,9 @@ public class LensBounce extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!isManaBlock && pos.entity == null && pos.getBlockPos() != null) {
if(!isManaBlock && pos.entity == null) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(!coords.equals(pos.getBlockPos())) {
if (!coords.equals(pos.getBlockPos())) {
Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
EnumFacing dir = pos.sideHit;
Vector3 normalVector = new Vector3(dir.getXOffset(), dir.getYOffset(), dir.getZOffset()).normalize();
@@ -23,7 +23,7 @@ public class LensExplosive extends Lens {
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake()) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(pos.entity == null && !isManaBlock && (pos.getBlockPos() == null || !coords.equals(pos.getBlockPos())))
if(pos.entity == null && !isManaBlock && !coords.equals(pos.getBlockPos()))
entity.world.createExplosion(entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true);
} else dead = false;
@@ -28,7 +28,7 @@ public class LensFire extends Lens {
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult rtr, boolean isManaBlock, boolean dead, ItemStack stack) {
BlockPos coords = burst.getBurstSourceBlockPos();
BlockPos pos = rtr.getBlockPos();
if(!entity.world.isRemote && pos != null && !coords.equals(pos) && !burst.isFake() && !isManaBlock) {
if(!entity.world.isRemote && !coords.equals(pos) && !burst.isFake() && !isManaBlock) {
EnumFacing dir = rtr.sideHit;
BlockPos offPos = pos.offset(dir);
@@ -27,7 +27,7 @@ public class LensFirework extends Lens {
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake()) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(pos.entity == null && !isManaBlock && (pos.getBlockPos() == null || !pos.getBlockPos().equals(coords))) {
if(pos.entity == null && !isManaBlock && !pos.getBlockPos().equals(coords)) {
ItemStack fireworkStack = generateFirework(burst.getColor());
EntityFireworkRocket rocket = new EntityFireworkRocket(entity.world, entity.posX, entity.posY, entity.posZ, fireworkStack);
@@ -38,10 +38,10 @@ public class LensFirework extends Lens {
return dead;
}
public ItemStack generateFirework(int color) {
private ItemStack generateFirework(int color) {
ItemStack stack = new ItemStack(Items.FIREWORK_ROCKET);
NBTTagCompound explosion = new NBTTagCompound();
explosion.setIntArray("Colors", new int[] { color });
explosion.putIntArray("Colors", new int[] { color });
int type = 1;
double rand = Math.random();
@@ -51,21 +51,21 @@ public class LensFirework extends Lens {
else type = 0;
}
explosion.setInt("Type", type);
explosion.putInt("Type", type);
if(Math.random() < 0.05)
if(Math.random() < 0.5)
explosion.setBoolean("Flicker", true);
else explosion.setBoolean("Trail", true);
explosion.putBoolean("Flicker", true);
else explosion.putBoolean("Trail", true);
ItemNBTHelper.setCompound(stack, "Explosion", explosion);
NBTTagCompound fireworks = new NBTTagCompound();
fireworks.setInt("Flight", (int) (Math.random() * 3 + 2));
fireworks.putInt("Flight", (int) (Math.random() * 3 + 2));
NBTTagList explosions = new NBTTagList();
explosions.add(explosion);
fireworks.setTag("Explosions", explosions);
fireworks.put("Explosions", explosions);
ItemNBTHelper.setCompound(stack, "Fireworks", fireworks);
@@ -28,7 +28,7 @@ public class LensMagnet extends Lens {
@Override
public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
BlockPos basePos = new BlockPos(entity);
boolean magnetized = entity.getData().hasKey(TAG_MAGNETIZED);
boolean magnetized = entity.getEntityData().contains(TAG_MAGNETIZED);
int range = 3;
magnetize : {
@@ -37,9 +37,9 @@ public class LensMagnet extends Lens {
TileEntity tile = entity.world.getTileEntity(pos);
if(magnetized) {
int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X);
int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y);
int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z);
int magX = entity.getEntityData().getInt(TAG_MAGNETIZED_X);
int magY = entity.getEntityData().getInt(TAG_MAGNETIZED_Y);
int magZ = entity.getEntityData().getInt(TAG_MAGNETIZED_Z);
if(tile.getPos().getX() != magX || tile.getPos().getY() != magY || tile.getPos().getZ() != magZ)
continue;
}
@@ -60,10 +60,10 @@ public class LensMagnet extends Lens {
Vector3 finalMotionVec = motionVec.subtract(differenceVec);
if(!magnetized) {
finalMotionVec = finalMotionVec.multiply(0.75);
entity.getEntityData().setBoolean(TAG_MAGNETIZED, true);
entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.getPos().getX());
entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.getPos().getY());
entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.getPos().getZ());
entity.getEntityData().putBoolean(TAG_MAGNETIZED, true);
entity.getEntityData().putInt(TAG_MAGNETIZED_X, tile.getPos().getX());
entity.getEntityData().putInt(TAG_MAGNETIZED_Y, tile.getPos().getY());
entity.getEntityData().putInt(TAG_MAGNETIZED_Z, tile.getPos().getZ());
}
burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z);
@@ -33,7 +33,7 @@ public class LensMine extends Lens {
World world = entity.world;
BlockPos collidePos = rtr.getBlockPos();
if (world.isRemote || collidePos == null)
if (world.isRemote)
return false;
IBlockState state = world.getBlockState(collidePos);
@@ -34,7 +34,7 @@ public class LensPaint extends Lens {
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
int storedColor = ItemLens.getStoredColor(stack);
if(!entity.world.isRemote && !burst.isFake() && storedColor > -1 && storedColor < 17) {
if(pos.entity != null && pos.entity instanceof EntitySheep) {
if(pos.entity instanceof EntitySheep) {
int r = 20;
EnumDyeColor sheepColor = ((EntitySheep) pos.entity).getFleeceColor();
List<EntitySheep> sheepList = entity.world.getEntitiesWithinAABB(EntitySheep.class, new AxisAlignedBB(pos.entity.posX - r, pos.entity.posY - r, pos.entity.posZ - r, pos.entity.posX + r, pos.entity.posY + r, pos.entity.posZ + r));
@@ -43,7 +43,7 @@ public class LensPaint extends Lens {
sheep.setFleeceColor(EnumDyeColor.byId(storedColor == 16 ? sheep.world.rand.nextInt(16) : storedColor));
}
dead = true;
} else if (pos.getBlockPos() != null) {
} else {
Block block = entity.world.getBlockState(pos.getBlockPos()).getBlock();
if(BotaniaAPI.paintableBlocks.containsKey(block)) {
IBlockState state = entity.world.getBlockState(pos.getBlockPos());
@@ -22,7 +22,7 @@ public class LensStorm extends Lens {
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake()) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(pos.entity == null && !isManaBlock && (pos.getBlockPos() == null || !coords.equals(pos.getBlockPos())))
if(pos.type == RayTraceResult.Type.BLOCK && !isManaBlock && !coords.equals(pos.getBlockPos()))
entity.world.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, true);
} else dead = false;
@@ -41,7 +41,7 @@ public class LensTripwire extends Lens {
List<EntityLivingBase> entities = entity.world.getEntitiesWithinAABB(EntityLivingBase.class, axis);
if(!entities.isEmpty()) {
Entity e = (Entity) burst;
e.getEntityData().setBoolean(TAG_TRIPPED, true);
e.getEntityData().putBoolean(TAG_TRIPPED, true);
}
}
@@ -25,18 +25,18 @@ public class LensWarp extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(burst.isFake() || pos.getBlockPos() == null)
if(burst.isFake() || pos.type != RayTraceResult.Type.BLOCK)
return dead;
Block block = entity.world.getBlockState(pos.getBlockPos()).getBlock();
if(block == ModBlocks.pistonRelay) {
BlockPistonRelay.DimWithPos key = ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(new BlockPistonRelay.DimWithPos(entity.world.provider.getDimension(), pos.getBlockPos()));
BlockPistonRelay.DimWithPos key = ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(new BlockPistonRelay.DimWithPos(entity.world.getDimension().getType(), pos.getBlockPos()));
if(key != null) {
if(key.dim == entity.world.getDimension().getId()) {
if(key.dim == entity.world.getDimension().getType()) {
entity.setPosition(key.blockPos.getX() + 0.5, key.blockPos.getY() + 0.5, key.blockPos.getZ() + 0.5);
burst.setCollidedAt(key.blockPos);
entity.getEntityData().setBoolean(TAG_WARPED, true);
entity.getEntityData().putBoolean(TAG_WARPED, true);
return false;
}
@@ -30,7 +30,7 @@ import java.util.Map;
public class LensWeight extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake() && pos.getBlockPos() != null) {
if(!entity.world.isRemote && !burst.isFake() && pos.type == RayTraceResult.Type.BLOCK) {
int harvestLevel = ConfigHandler.harvestLevelWeight;
BlockPos bPos = pos.getBlockPos();
@@ -11,28 +11,21 @@
package vazkii.botania.common.item.material;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCarpet;
import net.minecraft.block.BlockColored;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.item.Item16Colors;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
@@ -44,13 +37,14 @@ public class ItemDye extends Item16Colors {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
public EnumActionResult onItemUse(ItemUseContext ctx) {
ItemStack stack = ctx.getItem();
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.WOOL && color != world.getBlockState(pos).getValue(BlockColored.COLOR)
|| block == Blocks.CARPET && color != world.getBlockState(pos).getValue(BlockCarpet.COLOR)) {
world.setBlockState(pos, world.getBlockState(pos).with(block == Blocks.WOOL ? BlockColored.COLOR : BlockCarpet.COLOR, color), 1 | 2);
if(shouldRecolor(block)) {
world.setBlockState(pos, recolor(block, color));
stack.shrink(1);
return EnumActionResult.SUCCESS;
}
@@ -83,4 +77,23 @@ public class ItemDye extends Item16Colors {
return false;
}
// todo 1.13 yikes is there a better way?
private boolean shouldRecolor(Block block) {
if (block.getRegistryName().getNamespace().equals("minecraft")
&& (block.getRegistryName().getPath().contains("_carpet")
|| block.getRegistryName().getPath().contains("_wool"))) {
String blockColor = block.getRegistryName().getPath().split("_")[0];
return !blockColor.equals(this.color.getName());
}
return false;
}
private IBlockState recolor(Block original, EnumDyeColor color) {
if (original.getRegistryName().getPath().contains("_carpet")) {
return ModBlocks.getCarpet(color).getDefaultState();
} else {
return ModBlocks.getWool(color).getDefaultState();
}
}
}
@@ -26,6 +26,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.api.wand.ICoordBoundItem;
@@ -70,7 +71,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
ItemNBTHelper.setInt(stack, TAG_X, pos.getX());
ItemNBTHelper.setInt(stack, TAG_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_Z, pos.getZ());
ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.getDimension());
ItemNBTHelper.setString(stack, TAG_DIMENSION, world.getDimension().getType().toString());
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 5F);
}
@@ -105,11 +106,11 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
int x = ItemNBTHelper.getInt(stack, TAG_X, 0);
int y = ItemNBTHelper.getInt(stack, TAG_Y, -1);
int z = ItemNBTHelper.getInt(stack, TAG_Z, 0);
int dim = ItemNBTHelper.getInt(stack, TAG_DIMENSION, 0);
DimensionType dim = DimensionType.byName(new ResourceLocation(ItemNBTHelper.getString(stack, TAG_DIMENSION, "minecraft:overworld")));
int cost = (int) (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, player.posX, player.posY, player.posZ) * 10);
if(y > -1 && dim == world.provider.getDimension() && ManaItemHandler.requestManaExact(stack, player, cost, true)) {
if(y > -1 && dim == world.getDimension().getType() && ManaItemHandler.requestManaExact(stack, player, cost, true)) {
moveParticlesAndSound(player);
if(player instanceof EntityPlayerMP)
((EntityPlayerMP) player).connection.setPlayerLocation(x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch);
@@ -30,8 +30,8 @@ import java.util.Locale;
public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
public ItemInfiniteFruit() {
super(LibItemNames.INFINITE_FRUIT);
public ItemInfiniteFruit(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "boot"), (stack, worldIn, entityIn) -> ItemInfiniteFruit.isBoot(stack) ? 1F : 0F);
}
@@ -21,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -89,7 +90,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
List<BlockPos> cursors = getCursorList(lokiRing);
int cost = Math.min(cursors.size(), (int) Math.pow(Math.E, cursors.size() * 0.25));
if(lookPos == null || lookPos.getBlockPos() == null)
if(lookPos == null)
return;
if(heldItemStack.isEmpty()) {
@@ -126,10 +127,9 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
} else {
for(BlockPos cursor : cursors) {
BlockPos pos = lookPos.getBlockPos().add(cursor);
Item item = heldItemStack.getItem();
if(player.world.isAirBlock(pos) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) {
ItemStack saveHeld = heldItemStack.copy();
item.onItemUse(player, player.world, pos, event.getHand(), lookPos.sideHit, (float) lookPos.hitVec.x - pos.getX(), (float) lookPos.hitVec.y - pos.getY(), (float) lookPos.hitVec.z - pos.getZ());
heldItemStack.onItemUse(new ItemUseContext(player, heldItemStack, pos, lookPos.sideHit, (float) lookPos.hitVec.x - pos.getX(), (float) lookPos.hitVec.y - pos.getY(), (float) lookPos.hitVec.z - pos.getZ()));
if (player.isCreative())
player.setHeldItem(event.getHand(), saveHeld);
}
@@ -173,7 +173,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
RayTraceResult lookPos = Minecraft.getInstance().objectMouseOver;
if(lookPos != null && lookPos.getBlockPos() != null && !player.world.isAirBlock(lookPos.getBlockPos()) && lookPos.entityHit == null) {
if(lookPos != null && !player.world.isAirBlock(lookPos.getBlockPos()) && lookPos.entity == null) {
List<BlockPos> list = getCursorList(stack);
BlockPos origin = getOriginPos(stack);
@@ -87,15 +87,15 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, IBlockProvid
}
@Override
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) {
if(block == Blocks.DIRT && meta == 0)
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
if(block == Blocks.DIRT)
return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true);
return false;
}
@Override
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) {
if(block == Blocks.DIRT && meta == 0)
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block) {
if(block == Blocks.DIRT)
return -1;
return 0;
}
@@ -53,10 +53,8 @@ public class ItemSkyDirtRod extends ItemDirtRod {
if(entities == 0) {
ItemStack stackToPlace = new ItemStack(Blocks.DIRT);
player.setHeldItem(hand, stackToPlace);
ItemUseContext ctx = new ItemUseContext(player, stackToPlace, new BlockPos(x, y, z), EnumFacing.DOWN, 0, 0, 0);
stackToPlace.onItemUse(ctx);
player.setHeldItem(hand, stack);
if(stackToPlace.isEmpty()) {
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
@@ -20,7 +20,6 @@ import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
@@ -12,6 +12,7 @@ package vazkii.botania.common.item.rod;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@@ -117,7 +118,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
Block block_ = state_.getBlock();
if(state_.isAir(world, pos_) || block_.isReplaceable(state_, world, pos_)
|| block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower)
|| block_ == Blocks.DOUBLE_PLANT) {
|| block_ instanceof BlockDoublePlant) {
airBlocks.add(pos_);
}
}
@@ -167,15 +168,15 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
}
@Override
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) {
if(block == Blocks.DIRT && meta == 0)
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
if(block == Blocks.DIRT)
return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true);
return false;
}
@Override
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) {
if(block == Blocks.DIRT && meta == 0)
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block) {
if(block == Blocks.DIRT)
return -1;
return 0;
}
@@ -1,10 +1,21 @@
package vazkii.botania.common.item.rod;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.IBucketPickupHandler;
import net.minecraft.block.ILiquidContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.fluid.Fluid;
import net.minecraft.init.Fluids;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.stats.StatList;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -18,6 +29,7 @@ import vazkii.botania.common.item.ItemMod;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemWaterRod extends ItemMod implements IManaUsingItem {
@@ -27,33 +39,48 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
super(props);
}
// [VanillaCopy] From ItemBucket
@Nonnull
@Override
public EnumActionResult onItemUse(ItemUseContext ctx) {
ItemStack stack = player.getHeldItem(hand);
if(ManaItemHandler.requestManaExactForTool(stack, player, COST, false) && !world.provider.doesWaterVaporize()) {
// Adapted from bucket code
RayTraceResult mop = rayTrace(world, player, false);
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, false);
if (mop != null && mop.type == RayTraceResult.Type.BLOCK) {
BlockPos hitPos = mop.getBlockPos();
if(!world.isBlockModifiable(player, hitPos))
return EnumActionResult.FAIL;
BlockPos placePos = hitPos.offset(mop.sideHit);
if(player.canPlayerEdit(placePos, mop.sideHit, stack)) {
if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)
&& ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(player, world, placePos, mop)) {
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5);
return EnumActionResult.SUCCESS;
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemstack, raytraceresult);
if (ret != null) return ret;
if (raytraceresult == null) {
return new ActionResult<>(EnumActionResult.PASS, itemstack);
} else if (raytraceresult.type == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = raytraceresult.getBlockPos();
if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, raytraceresult.sideHit, itemstack)) {
IBlockState iblockstate = worldIn.getBlockState(blockpos);
BlockPos blockpos1 = this.getPlacementPosition(iblockstate, blockpos, raytraceresult);
if (ManaItemHandler.requestManaExactForTool(itemstack, playerIn, COST, true)
&& ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(playerIn, worldIn, blockpos1, raytraceresult)) {
if (playerIn instanceof EntityPlayerMP) {
CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)playerIn, blockpos1, itemstack);
}
playerIn.addStat(StatList.ITEM_USED.get(this));
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(blockpos1.getX() + Math.random(), blockpos1.getY() + Math.random(), blockpos1.getZ() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5);
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
} else {
return new ActionResult<>(EnumActionResult.FAIL, itemstack);
}
} else {
return new ActionResult<>(EnumActionResult.FAIL, itemstack);
}
return EnumActionResult.FAIL;
} else {
return new ActionResult<>(EnumActionResult.PASS, itemstack);
}
}
return EnumActionResult.PASS;
// [VanillaCopy] ItemBucket
private BlockPos getPlacementPosition(IBlockState p_210768_1_, BlockPos p_210768_2_, RayTraceResult p_210768_3_) {
return p_210768_1_.getBlock() instanceof ILiquidContainer ? p_210768_2_ : p_210768_3_.getBlockPos().offset(p_210768_3_.sideHit);
}
@Override