mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
Another pass through TE's. Things looking pretty good.
This commit is contained in:
1 parent
e1890a7aab
commit
4ad7e675eb
61 files changed
+919
-437
No files matched your search
@@ -822,15 +822,6 @@ public final class ModBlocks {
|
||||
}
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.BLAZE_BLOCK, blazeBlock);
|
||||
|
||||
// Vanilla OreDict entries
|
||||
OreDictionary.registerOre("hardenedClay", new ItemStack(Blocks.HARDENED_CLAY, 1, OreDictionary.WILDCARD_VALUE));
|
||||
OreDictionary.registerOre("snowLayer", Blocks.SNOW_LAYER);
|
||||
OreDictionary.registerOre("mycelium", Blocks.MYCELIUM);
|
||||
OreDictionary.registerOre("podzol", new ItemStack(Blocks.DIRT, 1, 2));
|
||||
OreDictionary.registerOre("soulSand", Blocks.SOUL_SAND);
|
||||
OreDictionary.registerOre("ice", Blocks.ICE);
|
||||
OreDictionary.registerOre("slabCobblestone", new ItemStack(Blocks.STONE_SLAB, 1, 3));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -77,6 +77,7 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
|
||||
// todo 1.13 move to extended state replacement
|
||||
builder.add(BotaniaStateProps.COLOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
@@ -41,6 +43,8 @@ import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -50,6 +54,9 @@ import java.util.function.Function;
|
||||
|
||||
public class TileAlfPortal extends TileMod implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ALF_PORTAL)
|
||||
public static TileEntityType<TileAlfPortal> TYPE;
|
||||
|
||||
private static final BlockPos[] LIVINGWOOD_POSITIONS = {
|
||||
new BlockPos(-1, 0, 0), new BlockPos(1, 0, 0), new BlockPos(-2, 1, 0),
|
||||
new BlockPos(2, 1, 0), new BlockPos(-2, 3, 0), new BlockPos(2, 3, 0),
|
||||
@@ -103,6 +110,10 @@ public class TileAlfPortal extends TileMod implements ITickable {
|
||||
return mb.makeSet();
|
||||
}
|
||||
|
||||
public TileAlfPortal() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
IBlockState iBlockState = world.getBlockState(getPos());
|
||||
|
||||
@@ -12,7 +12,6 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -26,7 +25,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -38,6 +37,7 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
@@ -48,6 +48,8 @@ import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
@@ -57,20 +59,26 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class TileAltar extends TileSimpleInventory implements IPetalApothecary, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ALTAR)
|
||||
public static TileEntityType<TileAltar> TYPE;
|
||||
private static final Pattern SEED_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)");
|
||||
private static final int SET_KEEP_TICKS_EVENT = 0;
|
||||
private static final int CRAFT_EFFECT_EVENT = 1;
|
||||
|
||||
public static final String TAG_HAS_WATER = "hasWater";
|
||||
public static final String TAG_HAS_LAVA = "hasLava";
|
||||
private static final String TAG_HAS_WATER = "hasWater";
|
||||
private static final String TAG_HAS_LAVA = "hasLava";
|
||||
|
||||
private static final String ITEM_TAG_APOTHECARY_SPAWNED = "ApothecarySpawned";
|
||||
|
||||
public boolean hasWater = false;
|
||||
public boolean hasLava = false;
|
||||
|
||||
List<ItemStack> lastRecipe = null;
|
||||
int recipeKeepTicks = 0;
|
||||
private List<ItemStack> lastRecipe = null;
|
||||
private int recipeKeepTicks = 0;
|
||||
|
||||
public TileAltar() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public boolean collideEntityItem(EntityItem item) {
|
||||
ItemStack stack = item.getItem();
|
||||
@@ -250,9 +258,9 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
}
|
||||
|
||||
if(hasLava()) {
|
||||
world.spawnParticle(Particles.SMOKE, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0);
|
||||
world.addParticle(Particles.SMOKE, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0);
|
||||
if(Math.random() > 0.9)
|
||||
world.spawnParticle(Particles.LAVA, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0);
|
||||
world.addParticle(Particles.LAVA, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,8 +273,8 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
super.writePacketNBT(cmp);
|
||||
|
||||
cmp.setBoolean(TAG_HAS_WATER, hasWater());
|
||||
cmp.setBoolean(TAG_HAS_LAVA, hasLava());
|
||||
cmp.putBoolean(TAG_HAS_WATER, hasWater());
|
||||
cmp.putBoolean(TAG_HAS_LAVA, hasLava());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,30 +11,36 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TileAnimatedTorch extends TileMod implements ITickable {
|
||||
|
||||
public static final String TAG_SIDE = "side";
|
||||
public static final String TAG_ROTATING = "rotating";
|
||||
public static final String TAG_ROTATION_TICKS = "rotationTicks";
|
||||
public static final String TAG_ANGLE_PER_TICK = "anglePerTick";
|
||||
public static final String TAG_TORCH_MODE = "torchMode";
|
||||
public static final String TAG_NEXT_RANDOM_ROTATION = "nextRandomRotation";
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ANIMATED_TORCH)
|
||||
public static TileEntityType<TileAnimatedTorch> TYPE;
|
||||
|
||||
private static final String TAG_SIDE = "side";
|
||||
private static final String TAG_ROTATING = "rotating";
|
||||
private static final String TAG_ROTATION_TICKS = "rotationTicks";
|
||||
private static final String TAG_ANGLE_PER_TICK = "anglePerTick";
|
||||
private static final String TAG_TORCH_MODE = "torchMode";
|
||||
private static final String TAG_NEXT_RANDOM_ROTATION = "nextRandomRotation";
|
||||
|
||||
public static final EnumFacing[] SIDES = new EnumFacing[] {
|
||||
EnumFacing.NORTH,
|
||||
@@ -55,6 +61,10 @@ public class TileAnimatedTorch extends TileMod implements ITickable {
|
||||
|
||||
private TorchMode torchMode = TorchMode.TOGGLE;
|
||||
|
||||
public TileAnimatedTorch() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if(!world.isRemote)
|
||||
@@ -116,7 +126,7 @@ public class TileAnimatedTorch extends TileMod implements ITickable {
|
||||
|
||||
// tell neighbors that signal is off because we are rotating
|
||||
world.notifyNeighborsOfStateChange(getPos(), getBlockState().getBlock());
|
||||
for(EnumFacing e : EnumFacing.VALUES) {
|
||||
for(EnumFacing e : EnumFacing.BY_INDEX) {
|
||||
world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockState().getBlock());
|
||||
}
|
||||
}
|
||||
@@ -127,7 +137,7 @@ public class TileAnimatedTorch extends TileMod implements ITickable {
|
||||
int y = mc.mainWindow.getScaledHeight() / 2 - 8;
|
||||
|
||||
mc.getItemRenderer().renderItemAndEffectIntoGUI(new ItemStack(Blocks.REDSTONE_TORCH), x, y);
|
||||
mc.fontRenderer.drawStringWithShadow(I18n.translateToLocal("botania.animatedTorch." + torchMode.name().toLowerCase()), x + 18, y + 6, 0xFF4444);
|
||||
mc.fontRenderer.drawStringWithShadow(I18n.format("botania.animatedTorch." + torchMode.name().toLowerCase()), x + 18, y + 6, 0xFF4444);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,18 +165,18 @@ public class TileAnimatedTorch extends TileMod implements ITickable {
|
||||
double z = getPos().getZ() + 0.5 + Math.sin((rotation + 90) / 180.0 * Math.PI) * 0.35;
|
||||
|
||||
for(int i = 0; i < amt; i++)
|
||||
world.spawnParticle(EnumParticleTypes.REDSTONE, x, y, z, 0.0D, 0.0D, 0.0D);
|
||||
world.addParticle(RedstoneParticleData.REDSTONE_DUST, x, y, z, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_SIDE, side);
|
||||
cmp.setBoolean(TAG_ROTATING, rotating);
|
||||
cmp.setInt(TAG_ROTATION_TICKS, rotationTicks);
|
||||
cmp.setDouble(TAG_ANGLE_PER_TICK, anglePerTick);
|
||||
cmp.setInt(TAG_TORCH_MODE, torchMode.ordinal());
|
||||
cmp.setInt(TAG_NEXT_RANDOM_ROTATION, nextRandomRotation);
|
||||
cmp.putInt(TAG_SIDE, side);
|
||||
cmp.putBoolean(TAG_ROTATING, rotating);
|
||||
cmp.putInt(TAG_ROTATION_TICKS, rotationTicks);
|
||||
cmp.putDouble(TAG_ANGLE_PER_TICK, anglePerTick);
|
||||
cmp.putInt(TAG_TORCH_MODE, torchMode.ordinal());
|
||||
cmp.putInt(TAG_NEXT_RANDOM_ROTATION, nextRandomRotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,26 +12,37 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.AVATAR)
|
||||
public static TileEntityType<TileAvatar> TYPE;
|
||||
|
||||
private static final int MAX_MANA = 6400;
|
||||
|
||||
private static final String TAG_ENABLED = "enabled";
|
||||
private static final String TAG_TICKS_ELAPSED = "ticksElapsed";
|
||||
private static final String TAG_MANA = "ticksElapsed";
|
||||
|
||||
boolean enabled;
|
||||
int ticksElapsed;
|
||||
int mana;
|
||||
private boolean enabled;
|
||||
private int ticksElapsed;
|
||||
private int mana;
|
||||
|
||||
public TileAvatar() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -57,9 +68,9 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITic
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled);
|
||||
par1nbtTagCompound.setInt(TAG_TICKS_ELAPSED, ticksElapsed);
|
||||
par1nbtTagCompound.setInt(TAG_MANA, mana);
|
||||
par1nbtTagCompound.putBoolean(TAG_ENABLED, enabled);
|
||||
par1nbtTagCompound.putInt(TAG_TICKS_ELAPSED, ticksElapsed);
|
||||
par1nbtTagCompound.putInt(TAG_MANA, mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,17 +11,27 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileBifrost extends TileMod implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BIFROST)
|
||||
public static TileEntityType<TileBifrost> TYPE;
|
||||
private static final String TAG_TICKS = "ticks";
|
||||
|
||||
public int ticks = 0;
|
||||
|
||||
public TileBifrost() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if(!world.isRemote) {
|
||||
@@ -35,7 +45,7 @@ public class TileBifrost extends TileMod implements ITickable {
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound par1nbtTagCompound) {
|
||||
NBTTagCompound ret = super.write(par1nbtTagCompound);
|
||||
ret.setInt(TAG_TICKS, ticks);
|
||||
ret.putInt(TAG_TICKS, ticks);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,16 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.IBrewContainer;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
@@ -31,6 +32,8 @@ import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketBotaniaEffect;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
|
||||
@@ -41,14 +44,20 @@ import java.util.List;
|
||||
|
||||
public class TileBrewery extends TileSimpleInventory implements IManaReceiver, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BREWERY)
|
||||
public static TileEntityType<TileBrewery> TYPE;
|
||||
private static final String TAG_MANA = "mana";
|
||||
private static final int CRAFT_EFFECT_EVENT = 0;
|
||||
|
||||
public RecipeBrew recipe;
|
||||
int mana = 0;
|
||||
int manaLastTick = 0;
|
||||
private int mana = 0;
|
||||
private int manaLastTick = 0;
|
||||
public int signal = 0;
|
||||
|
||||
public TileBrewery() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public boolean addItem(@Nullable EntityPlayer player, ItemStack stack, @Nullable EnumHand hand) {
|
||||
if(recipe != null || stack.isEmpty() || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0).isEmpty() != stack.getItem() instanceof IBrewContainer)
|
||||
return false;
|
||||
@@ -187,7 +196,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
|
||||
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
|
||||
par1nbtTagCompound.setInt(TAG_MANA, mana);
|
||||
par1nbtTagCompound.putInt(TAG_MANA, mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,15 +12,25 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.item.ItemCacophonium;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileCacophonium extends TileMod {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CACOPHONIUM)
|
||||
public static TileEntityType<TileCacophonium> TYPE;
|
||||
private static final String TAG_STACK = "stack";
|
||||
|
||||
public ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
public TileCacophonium() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void annoyDirewolf() {
|
||||
ItemCacophonium.playSound(world, stack, pos.getX(), pos.getY(), pos.getZ(), SoundCategory.BLOCKS, 1F);
|
||||
}
|
||||
@@ -32,7 +42,7 @@ public class TileCacophonium extends TileMod {
|
||||
NBTTagCompound cmp1 = new NBTTagCompound();
|
||||
if(!stack.isEmpty())
|
||||
cmp1 = stack.write(cmp1);
|
||||
cmp.setTag(TAG_STACK, cmp1);
|
||||
cmp.put(TAG_STACK, cmp1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
public class TileCamo extends TileMod {
|
||||
|
||||
@@ -24,10 +23,14 @@ public class TileCamo extends TileMod {
|
||||
|
||||
public IBlockState camoState;
|
||||
|
||||
public TileCamo(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
if(camoState != null) {
|
||||
cmp.setTag(TAG_CAMO, NBTUtil.writeBlockState(camoState));
|
||||
cmp.put(TAG_CAMO, NBTUtil.writeBlockState(camoState));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,16 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileCell extends TileMod {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CELL_BLOCK)
|
||||
public static TileEntityType<TileCell> TYPE;
|
||||
private static final String TAG_GENERATION = "generation";
|
||||
private static final String TAG_TICKED = "ticked";
|
||||
private static final String TAG_FLOWER_X = "flowerX";
|
||||
@@ -30,6 +36,10 @@ public class TileCell extends TileMod {
|
||||
private BlockPos flowerCoords = new BlockPos(0, -1, 0);
|
||||
private BlockPos validCoords = new BlockPos(0, -1, 0);
|
||||
|
||||
public TileCell() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void setGeneration(TileEntity flower, int gen) {
|
||||
generation = gen;
|
||||
if(!ticked) {
|
||||
|
||||
@@ -26,11 +26,18 @@ import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileCocoon extends TileMod implements ITickable{
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.COCOON)
|
||||
public static TileEntityType<TileCocoon> TYPE;
|
||||
|
||||
private static final String TAG_TIME_PASSED = "timePassed";
|
||||
private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven";
|
||||
private static final String TAG_CHORUS_FRUIT_GIVEN = "chorusFruitGiven";
|
||||
@@ -43,6 +50,10 @@ public class TileCocoon extends TileMod implements ITickable{
|
||||
public int emeraldsGiven;
|
||||
public int chorusFruitGiven;
|
||||
|
||||
public TileCocoon() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
timePassed++;
|
||||
@@ -123,9 +134,9 @@ public class TileCocoon extends TileMod implements ITickable{
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_TIME_PASSED, timePassed);
|
||||
cmp.setInt(TAG_EMERALDS_GIVEN, emeraldsGiven);
|
||||
cmp.setInt(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven);
|
||||
cmp.putInt(TAG_TIME_PASSED, timePassed);
|
||||
cmp.putInt(TAG_EMERALDS_GIVEN, emeraldsGiven);
|
||||
cmp.putInt(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,21 +18,31 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.state.enums.CratePattern;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class TileCraftCrate extends TileOpenCrate {
|
||||
public static final String TAG_PATTERN = "pattern";
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CRAFT_CRATE)
|
||||
public static TileEntityType<TileCraftCrate> TYPE;
|
||||
private static final String TAG_PATTERN = "pattern";
|
||||
|
||||
public CratePattern pattern = CratePattern.NONE;
|
||||
private int signal = 0;
|
||||
|
||||
public TileCraftCrate() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 10;
|
||||
@@ -98,7 +108,7 @@ public class TileCraftCrate extends TileOpenCrate {
|
||||
craft.setInventorySlotContents(i, stack);
|
||||
}
|
||||
|
||||
for(IRecipe recipe : ForgeRegistries.RECIPES)
|
||||
for(IRecipe recipe : world.getRecipeManager().getRecipes(VanillaRecipeTypes.CRAFTING))
|
||||
if(recipe.matches(craft, world)) {
|
||||
itemHandler.setStackInSlot(9, recipe.getCraftingResult(craft));
|
||||
|
||||
@@ -133,7 +143,7 @@ public class TileCraftCrate extends TileOpenCrate {
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setInt(TAG_PATTERN, pattern.ordinal());
|
||||
par1nbtTagCompound.putInt(TAG_PATTERN, pattern.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,14 +27,19 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.ResourceLocationException;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
@@ -49,6 +54,8 @@ import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketBotaniaEffect;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
|
||||
@@ -61,6 +68,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class TileEnchanter extends TileMod implements ISparkAttachable, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ENCHANTER)
|
||||
public static TileEntityType<TileEnchanter> TYPE;
|
||||
private static final String TAG_STAGE = "stage";
|
||||
private static final String TAG_STAGE_TICKS = "stageTicks";
|
||||
private static final String TAG_STAGE_3_END_TICKS = "stage3EndTicks";
|
||||
@@ -118,6 +127,10 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
|
||||
return mb.makeSet();
|
||||
}
|
||||
|
||||
public TileEnchanter() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void onWanded(EntityPlayer player, ItemStack wand) {
|
||||
if(stage != State.IDLE || itemToEnchant.isEmpty() || !itemToEnchant.isEnchantable())
|
||||
return;
|
||||
@@ -341,21 +354,21 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_MANA, mana);
|
||||
cmp.setInt(TAG_MANA_REQUIRED, manaRequired);
|
||||
cmp.setInt(TAG_STAGE, stage.ordinal());
|
||||
cmp.setInt(TAG_STAGE_TICKS, stageTicks);
|
||||
cmp.setInt(TAG_STAGE_3_END_TICKS, stage3EndTicks);
|
||||
cmp.putInt(TAG_MANA, mana);
|
||||
cmp.putInt(TAG_MANA_REQUIRED, manaRequired);
|
||||
cmp.putInt(TAG_STAGE, stage.ordinal());
|
||||
cmp.putInt(TAG_STAGE_TICKS, stageTicks);
|
||||
cmp.putInt(TAG_STAGE_3_END_TICKS, stage3EndTicks);
|
||||
|
||||
NBTTagCompound itemCmp = new NBTTagCompound();
|
||||
if(!itemToEnchant.isEmpty())
|
||||
itemCmp = itemToEnchant.write(itemCmp);
|
||||
cmp.setTag(TAG_ITEM, itemCmp);
|
||||
cmp.put(TAG_ITEM, itemCmp);
|
||||
|
||||
String enchStr = enchants.stream()
|
||||
.map(e -> Enchantment.REGISTRY.getNameForObject(e.enchantment) + "=" + e.enchantmentLevel)
|
||||
.map(e -> IRegistry.ENCHANTMENT.getKey(e.enchantment) + "=" + e.enchantmentLevel)
|
||||
.collect(Collectors.joining(","));
|
||||
cmp.setString(TAG_ENCHANTS, enchStr);
|
||||
cmp.putString(TAG_ENCHANTS, enchStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,10 +387,12 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
|
||||
if(!enchStr.isEmpty()) {
|
||||
String[] enchTokens = enchStr.split(",");
|
||||
for(String token : enchTokens) {
|
||||
String[] entryTokens = token.split("=");
|
||||
Enchantment ench = Enchantment.getEnchantmentByLocation(entryTokens[0]);
|
||||
int lvl = Integer.parseInt(entryTokens[1]);
|
||||
enchants.add(new EnchantmentData(ench, lvl));
|
||||
try {
|
||||
String[] entryTokens = token.split("=");
|
||||
Enchantment ench = IRegistry.ENCHANTMENT.get(new ResourceLocation(entryTokens[0]));
|
||||
int lvl = Integer.parseInt(entryTokens[1]);
|
||||
enchants.add(new EnchantmentData(ench, lvl));
|
||||
} catch (ResourceLocationException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,17 +15,27 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEnderEye extends TileMod implements ITickable {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ENDER_EYE_BLOCK)
|
||||
public static TileEntityType<TileEnderEye> TYPE;
|
||||
|
||||
public TileEnderEye() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -57,7 +67,7 @@ public class TileEnderEye extends TileMod implements ITickable {
|
||||
double y = getPos().getY() - 0.1 + Math.random() * 1.2;
|
||||
double z = getPos().getZ() - 0.1 + Math.random() * 1.2;
|
||||
|
||||
((WorldServer) world).spawnParticle(EnumParticleTypes.REDSTONE, false, x, y, z, 0, 1.0D, 0.0D, 0.0D, 1.0D);
|
||||
((WorldServer) world).spawnParticle(RedstoneParticleData.REDSTONE_DUST, x, y, z, 0, 1.0D, 0.0D, 0.0D, 1.0D);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,19 +12,29 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileBubbell;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileFakeAir extends TileMod {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FAKE_AIR)
|
||||
public static TileEntityType<TileFakeAir> TYPE;
|
||||
private static final String TAG_FLOWER_X = "flowerX";
|
||||
private static final String TAG_FLOWER_Y = "flowerY";
|
||||
private static final String TAG_FLOWER_Z = "flowerZ";
|
||||
|
||||
private BlockPos flowerPos = BlockPos.ORIGIN;
|
||||
|
||||
public TileFakeAir() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void setFlower(TileEntity tile) {
|
||||
flowerPos = tile.getPos();
|
||||
}
|
||||
@@ -37,9 +47,9 @@ public class TileFakeAir extends TileMod {
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound par1nbtTagCompound) {
|
||||
NBTTagCompound ret = super.write(par1nbtTagCompound);
|
||||
ret.setInt(TAG_FLOWER_X, flowerPos.getX());
|
||||
ret.setInt(TAG_FLOWER_Y, flowerPos.getY());
|
||||
ret.setInt(TAG_FLOWER_Z, flowerPos.getZ());
|
||||
ret.putInt(TAG_FLOWER_X, flowerPos.getX());
|
||||
ret.putInt(TAG_FLOWER_Y, flowerPos.getY());
|
||||
ret.putInt(TAG_FLOWER_Z, flowerPos.getZ());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,16 +13,27 @@ package vazkii.botania.common.block.tile;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileFloatingFlower extends TileMod implements IFloatingFlower {
|
||||
|
||||
public static final String TAG_ISLAND_TYPE = "islandType";
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MINI_ISLAND)
|
||||
public static TileEntityType<TileFloatingFlower> TYPE;
|
||||
private static final String TAG_ISLAND_TYPE = "islandType";
|
||||
public static ItemStack forcedStack = ItemStack.EMPTY;
|
||||
|
||||
IslandType type = IslandType.GRASS;
|
||||
|
||||
public TileFloatingFlower() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if(!forcedStack.isEmpty()) {
|
||||
@@ -30,9 +41,7 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower {
|
||||
forcedStack = ItemStack.EMPTY;
|
||||
return retStack;
|
||||
}
|
||||
EnumDyeColor color = world.getBlockState(getPos()).getBlock() != ModBlocks.floatingFlower ? EnumDyeColor.WHITE
|
||||
: world.getBlockState(getPos()).getValue(BotaniaStateProps.COLOR);
|
||||
return new ItemStack(ModBlocks.shinyFlower, 1, color.getMetadata());
|
||||
return new ItemStack(getBlockState().getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +56,7 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower {
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setString(TAG_ISLAND_TYPE, type.toString());
|
||||
cmp.putString(TAG_ISLAND_TYPE, type.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,13 +11,23 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileForestEye extends TileMod implements ITickable {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FOREST_EYE)
|
||||
public static TileEntityType<TileForestEye> TYPE;
|
||||
|
||||
public int entities = 0;
|
||||
|
||||
public TileForestEye() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (world.isRemote)
|
||||
|
||||
@@ -11,9 +11,21 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileGaiaHead extends TileEntitySkull {
|
||||
public TileGaiaHead() {
|
||||
setType(3);
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.GAIA_HEAD)
|
||||
public static TileEntityType<TileGaiaHead> TYPE;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TileEntityType<TileGaiaHead> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,6 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -20,21 +19,26 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.item.IHourglassTrigger;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileHourglass extends TileSimpleInventory implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.HOURGLASS)
|
||||
public static TileEntityType<TileHourglass> TYPE;
|
||||
private static final String TAG_TIME = "time";
|
||||
private static final String TAG_TIME_FRACTION = "timeFraction";
|
||||
private static final String TAG_FLIP = "flip";
|
||||
@@ -50,6 +54,10 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
|
||||
public boolean lock = false;
|
||||
public boolean move = true;
|
||||
|
||||
public TileHourglass() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
private boolean isDust() {
|
||||
ItemStack stack = itemHandler.getStackInSlot(0);
|
||||
return !stack.isEmpty() && stack.getItem() == ModItems.manaPowder;
|
||||
@@ -113,9 +121,11 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
|
||||
public static int getStackItemTime(ItemStack stack) {
|
||||
if(stack.isEmpty())
|
||||
return 0;
|
||||
if(stack.getItem() == Item.getItemFromBlock(Blocks.SAND))
|
||||
return stack.getItemDamage() == 1 ? 200 : 20;
|
||||
if(stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND))
|
||||
if(stack.getItem() == Blocks.SAND.asItem())
|
||||
return 20;
|
||||
if(stack.getItem() == Blocks.RED_SAND.asItem())
|
||||
return 200;
|
||||
if(stack.getItem() == Blocks.SOUL_SAND.asItem())
|
||||
return 1200;
|
||||
if(stack.getItem() == ModItems.manaPowder)
|
||||
return 1;
|
||||
@@ -126,9 +136,11 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
|
||||
ItemStack stack = itemHandler.getStackInSlot(0);
|
||||
if(stack.isEmpty())
|
||||
return 0;
|
||||
if(stack.getItem() == Item.getItemFromBlock(Blocks.SAND))
|
||||
return stack.getItemDamage() == 1 ? 0xE95800 : 0xFFEC49;
|
||||
if(stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND))
|
||||
if(stack.getItem() == Blocks.SAND.asItem())
|
||||
return 0xFFEC49;
|
||||
if(stack.getItem() == Blocks.RED_SAND.asItem())
|
||||
return 0xE95800;
|
||||
if(stack.getItem() == Blocks.SOUL_SAND.asItem())
|
||||
return 0x5A412f;
|
||||
if(stack.getItem() == ModItems.manaPowder)
|
||||
return 0x03abff;
|
||||
@@ -142,7 +154,10 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
if(!stack.isEmpty() && (stack.getItem() == Item.getItemFromBlock(Blocks.SAND) || stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND)) || stack.getItem() == ModItems.manaPowder)
|
||||
if(!stack.isEmpty() && (stack.getItem() == Blocks.SAND.asItem()
|
||||
|| stack.getItem() == Blocks.RED_SAND.asItem()
|
||||
|| stack.getItem() == Blocks.SOUL_SAND.asItem()
|
||||
|| stack.getItem() == ModItems.manaPowder))
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
else return stack;
|
||||
}
|
||||
@@ -162,12 +177,12 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setInt(TAG_TIME, time);
|
||||
par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction);
|
||||
par1nbtTagCompound.setBoolean(TAG_FLIP, flip);
|
||||
par1nbtTagCompound.setInt(TAG_FLIP_TICKS, flipTicks);
|
||||
par1nbtTagCompound.setBoolean(TAG_MOVE, move);
|
||||
par1nbtTagCompound.setBoolean(TAG_LOCK, lock);
|
||||
par1nbtTagCompound.putInt(TAG_TIME, time);
|
||||
par1nbtTagCompound.putFloat(TAG_TIME_FRACTION, timeFraction);
|
||||
par1nbtTagCompound.putBoolean(TAG_FLIP, flip);
|
||||
par1nbtTagCompound.putInt(TAG_FLIP_TICKS, flipTicks);
|
||||
par1nbtTagCompound.putBoolean(TAG_MOVE, move);
|
||||
par1nbtTagCompound.putBoolean(TAG_LOCK, lock);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,33 +16,41 @@ import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.brew.ItemIncenseStick;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
public class TileIncensePlate extends TileSimpleInventory implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.INCENSE_PLATE)
|
||||
public static TileEntityType<TileIncensePlate> TYPE;
|
||||
private static final String TAG_TIME_LEFT = "timeLeft";
|
||||
private static final String TAG_BURNING = "burning";
|
||||
private static final int RANGE = 32;
|
||||
|
||||
public int timeLeft = 0;
|
||||
private int timeLeft = 0;
|
||||
public boolean burning = false;
|
||||
|
||||
public int comparatorOutput = 0;
|
||||
|
||||
public TileIncensePlate() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
ItemStack stack = itemHandler.getStackInSlot(0);
|
||||
if(!stack.isEmpty() && burning) {
|
||||
Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack);
|
||||
@@ -109,14 +117,14 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickable {
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setInteger(TAG_TIME_LEFT, timeLeft);
|
||||
par1nbtTagCompound.setBoolean(TAG_BURNING, burning);
|
||||
par1nbtTagCompound.putInt(TAG_TIME_LEFT, timeLeft);
|
||||
par1nbtTagCompound.putBoolean(TAG_BURNING, burning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.readPacketNBT(par1nbtTagCompound);
|
||||
timeLeft = par1nbtTagCompound.getInteger(TAG_TIME_LEFT);
|
||||
timeLeft = par1nbtTagCompound.getInt(TAG_TIME_LEFT);
|
||||
burning = par1nbtTagCompound.getBoolean(TAG_BURNING);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
@@ -39,19 +40,22 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.LuminizerVariant;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.BlockLightRelay;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileLightRelay extends TileMod implements ITickable, IWandBindable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.LIGHT_RELAY)
|
||||
public static TileEntityType<TileLightRelay> TYPE;
|
||||
private static final int MAX_DIST = 20;
|
||||
|
||||
private static final String TAG_BIND_X = "bindX";
|
||||
@@ -61,9 +65,13 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
private BlockPos bindPos = new BlockPos(0, -1, 0);
|
||||
private int ticksElapsed = 0;
|
||||
|
||||
public TileLightRelay() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void mountEntity(Entity e) {
|
||||
BlockPos nextDest = getNextDestination();
|
||||
if(e.isRiding() || world.isRemote || nextDest == null || !isValidBinding())
|
||||
if(e.isPassenger()|| world.isRemote || nextDest == null || !isValidBinding())
|
||||
return;
|
||||
|
||||
EntityPlayerMover mover = new EntityPlayerMover(world, pos, nextDest);
|
||||
@@ -110,7 +118,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
BlockPos endpoint = getEndpoint();
|
||||
|
||||
if(endpoint != null) {
|
||||
AxisAlignedBB aabb = ModBlocks.lightRelay.getBoundingBox(world.getBlockState(pos), world, pos).offset(pos);
|
||||
AxisAlignedBB aabb = world.getBlockState(pos).getShape(world, pos).getBoundingBox().offset(pos);
|
||||
float range = 0.5F;
|
||||
List<EntityEnderPearl> enderPearls = world.getEntitiesWithinAABB(EntityEnderPearl.class, aabb.grow(range));
|
||||
for(EntityEnderPearl pearl : enderPearls) {
|
||||
@@ -131,7 +139,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
return false;
|
||||
|
||||
Block block = world.getBlockState(nextDest).getBlock();
|
||||
return block == ModBlocks.lightRelay;
|
||||
return block instanceof BlockLightRelay;
|
||||
}
|
||||
|
||||
private BlockPos getEndpoint() {
|
||||
@@ -176,9 +184,9 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
|
||||
public BlockPos getNextDestination() {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if(state.get(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.TOGGLE && state.get(BotaniaStateProps.POWERED))
|
||||
if(state.getBlock() == ModBlocks.lightRelayToggle && state.get(BotaniaStateProps.POWERED))
|
||||
return null;
|
||||
else if(state.get(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.FORK) {
|
||||
else if(state.getBlock() == ModBlocks.lightRelayFork) {
|
||||
BlockPos torchPos = null;
|
||||
for(int i = -2; i < 3; i++) {
|
||||
BlockPos testPos = pos.add(0, i, 0);
|
||||
@@ -196,7 +204,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
for(int i = 1; i < MAX_DIST; i++) {
|
||||
BlockPos testPos = pos.offset(side, i);
|
||||
IBlockState testState = world.getBlockState(testPos);
|
||||
if(testState.getBlock() == ModBlocks.lightRelay)
|
||||
if(testState.getBlock() instanceof BlockLightRelay)
|
||||
return testPos;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +220,8 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
|
||||
@Override
|
||||
public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) {
|
||||
if(player.world.getBlockState(pos).getBlock() != ModBlocks.lightRelay || pos.distanceSq(getPos()) > MAX_DIST * MAX_DIST)
|
||||
if(!(player.world.getBlockState(pos).getBlock() instanceof BlockLightRelay)
|
||||
|| pos.distanceSq(getPos()) > MAX_DIST * MAX_DIST)
|
||||
return false;
|
||||
|
||||
bindPos = pos;
|
||||
@@ -230,9 +239,9 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_BIND_X, bindPos.getX());
|
||||
cmp.setInt(TAG_BIND_Y, bindPos.getY());
|
||||
cmp.setInt(TAG_BIND_Z, bindPos.getZ());
|
||||
cmp.putInt(TAG_BIND_X, bindPos.getX());
|
||||
cmp.putInt(TAG_BIND_Y, bindPos.getY());
|
||||
cmp.putInt(TAG_BIND_Z, bindPos.getZ());
|
||||
}
|
||||
|
||||
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
|
||||
@@ -246,6 +255,8 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
|
||||
public EntityPlayerMover(World world) {
|
||||
super(world);
|
||||
setSize(0F, 0F);
|
||||
noClip = true;
|
||||
}
|
||||
|
||||
public EntityPlayerMover(World world, BlockPos pos, BlockPos exitPos) {
|
||||
@@ -255,9 +266,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
setSize(0F, 0F);
|
||||
noClip = true;
|
||||
protected void registerData() {
|
||||
dataManager.register(EXIT_POS, BlockPos.ORIGIN);
|
||||
}
|
||||
|
||||
@@ -279,10 +288,11 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
|
||||
if(pos.equals(exitPos)) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile != null && tile instanceof TileLightRelay) {
|
||||
if(world.getBlockState(pos).getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.DETECTOR) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BotaniaStateProps.POWERED, true), 1 | 2);
|
||||
world.scheduleUpdate(pos, tile.getBlockType(), tile.getBlockType().tickRate(world));
|
||||
if(tile instanceof TileLightRelay) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if(state.getBlock() == ModBlocks.lightRelayDetector) {
|
||||
world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true));
|
||||
world.getPendingBlockTicks().scheduleTick(pos, state.getBlock(), state.getBlock().tickRate(world));
|
||||
}
|
||||
|
||||
TileLightRelay relay = (TileLightRelay) tile;
|
||||
@@ -295,9 +305,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
|
||||
for(Entity e : getPassengers()) {
|
||||
e.stopRiding();
|
||||
if(e instanceof EntityPlayerMP)
|
||||
((EntityPlayerMP) e).connection.setPlayerLocation(posX, posY, posZ, e.rotationYaw, e.rotationPitch);
|
||||
else e.setPosition(posX, posY, posZ);
|
||||
e.setPositionAndUpdate(posX, posY, posZ);
|
||||
}
|
||||
remove();
|
||||
} else {
|
||||
@@ -341,9 +349,9 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
|
||||
@Override
|
||||
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
|
||||
BlockPos exit = getExitPos();
|
||||
cmp.setInt(TAG_EXIT_X, exit.getX());
|
||||
cmp.setInt(TAG_EXIT_Y, exit.getY());
|
||||
cmp.setInt(TAG_EXIT_Z, exit.getZ());
|
||||
cmp.putInt(TAG_EXIT_X, exit.getX());
|
||||
cmp.putInt(TAG_EXIT_Y, exit.getY());
|
||||
cmp.putInt(TAG_EXIT_Z, exit.getZ());
|
||||
}
|
||||
|
||||
public BlockPos getExitPos() {
|
||||
|
||||
@@ -11,16 +11,25 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileManaFlame extends TileMod implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_FLAME)
|
||||
public static TileEntityType<TileManaFlame> TYPE;
|
||||
private static final String TAG_COLOR = "color";
|
||||
|
||||
private int color = 0x20FF20;
|
||||
private int lightColor = -1;
|
||||
|
||||
public TileManaFlame() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
@@ -71,7 +80,7 @@ public class TileManaFlame extends TileMod implements ITickable {
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_COLOR, color);
|
||||
cmp.putInt(TAG_COLOR, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,20 +10,17 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileMod extends TileEntity {
|
||||
public TileMod(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
public TileMod(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -15,24 +15,31 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileOpenCrate extends TileSimpleInventory implements ITickable {
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState) {
|
||||
if(oldState.getBlock() != newState.getBlock())
|
||||
return true;
|
||||
if(oldState.getBlock() != ModBlocks.openCrate || newState.getBlock() != ModBlocks.openCrate)
|
||||
return true;
|
||||
return false;
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.OPEN_CRATE)
|
||||
public static TileEntityType<?> TYPE;
|
||||
|
||||
public TileOpenCrate() {
|
||||
this(TYPE);
|
||||
}
|
||||
|
||||
public TileOpenCrate(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,9 +69,7 @@ public class TileOpenCrate extends TileSimpleInventory implements ITickable {
|
||||
}
|
||||
|
||||
public boolean canEject() {
|
||||
IBlockState stateBelow = world.getBlockState(pos.down());
|
||||
Block blockBelow = stateBelow.getBlock();
|
||||
return blockBelow.isAir(stateBelow, world, pos.down()) || stateBelow.getCollisionBoundingBox(world, pos.down()) == null;
|
||||
return world.isCollisionBoxesEmpty(null, new AxisAlignedBB(pos.down()));
|
||||
}
|
||||
|
||||
public void eject(ItemStack stack, boolean redstone) {
|
||||
|
||||
@@ -12,10 +12,20 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TilePlatform extends TileCamo {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PLATFORM)
|
||||
public static TileEntityType<TilePlatform> TYPE;
|
||||
|
||||
public TilePlatform() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public boolean onWanded(EntityPlayer player) {
|
||||
if(player != null) {
|
||||
@@ -28,24 +38,24 @@ public class TilePlatform extends TileCamo {
|
||||
return false;
|
||||
}
|
||||
|
||||
void swapSelfAndPass(TilePlatform tile, boolean empty) {
|
||||
private void swapSelfAndPass(TilePlatform tile, boolean empty) {
|
||||
swap(tile, empty);
|
||||
swapSurroudings(tile, empty);
|
||||
}
|
||||
|
||||
void swapSurroudings(TilePlatform tile, boolean empty) {
|
||||
private void swapSurroudings(TilePlatform tile, boolean empty) {
|
||||
for(EnumFacing dir : EnumFacing.BY_INDEX) {
|
||||
BlockPos pos = tile.getPos().offset(dir);
|
||||
TileEntity tileAt = world.getTileEntity(pos);
|
||||
if(tileAt != null && tileAt instanceof TilePlatform) {
|
||||
if(tileAt instanceof TilePlatform) {
|
||||
TilePlatform platform = (TilePlatform) tileAt;
|
||||
if(empty ? platform.camoState != null : platform.camoState == null)
|
||||
if(empty == (platform.camoState != null))
|
||||
swapSelfAndPass(platform, empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void swap(TilePlatform tile, boolean empty) {
|
||||
private void swap(TilePlatform tile, boolean empty) {
|
||||
tile.camoState = empty ? null : camoState;
|
||||
world.notifyBlockUpdate(tile.getPos(), world.getBlockState(tile.getPos()), world.getBlockState(tile.getPos()), 8);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.AlfPortalState;
|
||||
import vazkii.botania.common.Botania;
|
||||
@@ -22,14 +24,21 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.mana.BlockPool;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TilePylon extends TileEntity implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PYLON)
|
||||
public static TileEntityType<TilePylon> TYPE;
|
||||
boolean activated = false;
|
||||
BlockPos centerPos;
|
||||
int ticks = 0;
|
||||
private int ticks = 0;
|
||||
|
||||
public TilePylon() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -19,10 +18,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
@@ -36,6 +37,8 @@ import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.material.ItemRune;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketBotaniaEffect;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
|
||||
@@ -45,30 +48,35 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RUNE_ALTAR)
|
||||
public static TileEntityType<TileRuneAltar> TYPE;
|
||||
private static final String TAG_MANA = "mana";
|
||||
private static final String TAG_MANA_TO_GET = "manaToGet";
|
||||
private static final int SET_KEEP_TICKS_EVENT = 0;
|
||||
private static final int SET_COOLDOWN_EVENT = 1;
|
||||
private static final int CRAFT_EFFECT_EVENT = 2;
|
||||
|
||||
RecipeRuneAltar currentRecipe;
|
||||
private RecipeRuneAltar currentRecipe;
|
||||
|
||||
public int manaToGet = 0;
|
||||
int mana = 0;
|
||||
int cooldown = 0;
|
||||
private int mana = 0;
|
||||
private int cooldown = 0;
|
||||
public int signal = 0;
|
||||
|
||||
List<ItemStack> lastRecipe = null;
|
||||
int recipeKeepTicks = 0;
|
||||
private List<ItemStack> lastRecipe = null;
|
||||
private int recipeKeepTicks = 0;
|
||||
|
||||
public TileRuneAltar() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public boolean addItem(@Nullable EntityPlayer player, ItemStack stack, @Nullable EnumHand hand) {
|
||||
if(cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon)
|
||||
return false;
|
||||
|
||||
if(stack.getItem() == Item.getItemFromBlock(ModBlocks.livingrock) && stack.getItemDamage() == 0) {
|
||||
if(stack.getItem() == ModBlocks.livingrock.asItem()) {
|
||||
if(!world.isRemote) {
|
||||
ItemStack toSpawn = player != null && player.abilities.isCreativeMode ? stack.copy().splitStack(1) : stack.splitStack(1);
|
||||
ItemStack toSpawn = player != null && player.abilities.isCreativeMode ? stack.copy().split(1) : stack.split(1);
|
||||
EntityItem item = new EntityItem(world, getPos().getX() + 0.5, getPos().getY() + 1, getPos().getZ() + 0.5, toSpawn);
|
||||
item.setPickupDelay(40);
|
||||
item.motionX = item.motionY = item.motionZ = 0;
|
||||
@@ -173,7 +181,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
else lastRecipe = null;
|
||||
}
|
||||
|
||||
public void updateRecipe() {
|
||||
private void updateRecipe() {
|
||||
int manaToGet = this.manaToGet;
|
||||
|
||||
getMana : {
|
||||
@@ -195,7 +203,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLastRecipe() {
|
||||
private void saveLastRecipe() {
|
||||
lastRecipe = new ArrayList<>();
|
||||
for(int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack stack = itemHandler.getStackInSlot(i);
|
||||
@@ -240,7 +248,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
|
||||
EntityItem livingrock = null;
|
||||
for(EntityItem item : items)
|
||||
if(item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) {
|
||||
if(item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() == ModBlocks.livingrock.asItem()) {
|
||||
livingrock = item;
|
||||
break;
|
||||
}
|
||||
@@ -259,7 +267,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
for(int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack stack = itemHandler.getStackInSlot(i);
|
||||
if(!stack.isEmpty()) {
|
||||
if(stack.getItem() instanceof ItemRune && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
if(stack.getItem() instanceof ItemRune && (player == null || !player.abilities.isCreativeMode)) {
|
||||
EntityItem outputRune = new EntityItem(world, getPos().getX() + 0.5, getPos().getY() + 1.5, getPos().getZ() + 0.5, stack.copy());
|
||||
world.spawnEntity(outputRune);
|
||||
}
|
||||
@@ -285,8 +293,8 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
|
||||
par1nbtTagCompound.setInt(TAG_MANA, mana);
|
||||
par1nbtTagCompound.setInt(TAG_MANA_TO_GET, manaToGet);
|
||||
par1nbtTagCompound.putInt(TAG_MANA, mana);
|
||||
par1nbtTagCompound.putInt(TAG_MANA_TO_GET, manaToGet);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -363,15 +371,15 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
float progress = (float) mana / (float) manaToGet;
|
||||
|
||||
mc.textureManager.bindTexture(HUDHandler.manaBar);
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
GlStateManager.color4f(1F, 1F, 1F, 1F);
|
||||
RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, progress == 1F ? 0 : 22, 8, 22, 15);
|
||||
|
||||
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
|
||||
if(progress == 1F) {
|
||||
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModBlocks.livingrock), xc + radius + 16, yc + 8);
|
||||
GlStateManager.translate(0F, 0F, 100F);
|
||||
GlStateManager.translatef(0F, 0F, 100F);
|
||||
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModItems.twigWand), xc + radius + 24, yc + 8);
|
||||
GlStateManager.translate(0F, 0F, -100F);
|
||||
GlStateManager.translatef(0F, 0F, -100F);
|
||||
}
|
||||
|
||||
RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput());
|
||||
@@ -385,9 +393,9 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
for(int i = 0; i < amt; i++) {
|
||||
double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8;
|
||||
double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8;
|
||||
GlStateManager.translate(xPos, yPos, 0);
|
||||
GlStateManager.translated(xPos, yPos, 0);
|
||||
mc.getItemRenderer().renderItemIntoGUI(itemHandler.getStackInSlot(i), 0, 0);
|
||||
GlStateManager.translate(-xPos, -yPos, 0);
|
||||
GlStateManager.translated(-xPos, -yPos, 0);
|
||||
|
||||
angle += anglePer;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -27,6 +28,10 @@ public abstract class TileSimpleInventory extends TileMod {
|
||||
protected SimpleItemStackHandler itemHandler = createItemHandler();
|
||||
private final LazyOptional<IItemHandler> automationItemHandler = LazyOptional.of(() -> itemHandler);
|
||||
|
||||
public TileSimpleInventory(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
itemHandler = createItemHandler();
|
||||
|
||||
@@ -12,13 +12,17 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
import vazkii.botania.api.mana.spark.SparkUpgradeType;
|
||||
import vazkii.botania.common.item.ItemSparkUpgrade;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -26,6 +30,12 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class TileSparkChanger extends TileSimpleInventory {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPARK_CHANGER)
|
||||
public static TileEntityType<TileSparkChanger> TYPE;
|
||||
|
||||
public TileSparkChanger() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void doSwap() {
|
||||
if(world.isRemote)
|
||||
|
||||
@@ -18,20 +18,29 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.WeightedSpawnerEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPAWNER_CLAW)
|
||||
public static TileEntityType<TileSpawnerClaw> TYPE;
|
||||
private static final String TAG_MANA = "mana";
|
||||
|
||||
int mana = 0;
|
||||
private int mana = 0;
|
||||
|
||||
public TileSpawnerClaw() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
@@ -116,9 +116,9 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
super.writePacketNBT(cmp);
|
||||
|
||||
cmp.setString(TAG_SUBTILE_NAME, subTileName.toString());
|
||||
cmp.putString(TAG_SUBTILE_NAME, subTileName.toString());
|
||||
NBTTagCompound subCmp = new NBTTagCompound();
|
||||
cmp.setTag(TAG_SUBTILE_CMP, subCmp);
|
||||
cmp.put(TAG_SUBTILE_CMP, subCmp);
|
||||
|
||||
if(subTile != null)
|
||||
subTile.writeToPacketNBTInternal(subCmp);
|
||||
@@ -180,9 +180,9 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
public void renderHUD(Minecraft mc) {
|
||||
if(subTile != null)
|
||||
subTile.renderHUD(mc, res);
|
||||
subTile.renderHUD(mc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,11 @@ import vazkii.botania.common.Botania;
|
||||
|
||||
public class TileSpiritShrine extends TileMod implements ITickable {
|
||||
|
||||
int ticks;
|
||||
private int ticks;
|
||||
|
||||
public TileSpiritShrine() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
@@ -10,11 +10,21 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileStarfield extends TileMod implements ITickable {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.STARFIELD)
|
||||
public static TileEntityType<TileStarfield> TYPE;
|
||||
|
||||
public TileStarfield() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
@@ -17,10 +17,12 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
@@ -32,13 +34,16 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketBotaniaEffect;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TERRA_PLATE)
|
||||
public static TileEntityType<TileTerraPlate> TYPE;
|
||||
public static final int MAX_MANA = TilePool.MAX_MANA / 2;
|
||||
|
||||
private static final BlockPos[] LAPIS_BLOCKS = {
|
||||
@@ -54,7 +59,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
|
||||
int mana;
|
||||
private int mana;
|
||||
|
||||
public static MultiblockSet makeMultiblockSet() {
|
||||
Multiblock mb = new Multiblock();
|
||||
@@ -70,6 +75,10 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
return mb.makeSet();
|
||||
}
|
||||
|
||||
public TileTerraPlate() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if(world.isRemote)
|
||||
@@ -120,7 +129,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
return world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
|
||||
}
|
||||
|
||||
boolean areItemsValid(List<EntityItem> items) {
|
||||
private boolean areItemsValid(List<EntityItem> items) {
|
||||
if(items.size() != 3)
|
||||
return false;
|
||||
|
||||
@@ -144,11 +153,11 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
return !ingot.isEmpty() && !pearl.isEmpty() && !diamond.isEmpty();
|
||||
}
|
||||
|
||||
boolean hasValidPlatform() {
|
||||
private boolean hasValidPlatform() {
|
||||
return checkAll(LAPIS_BLOCKS, Blocks.LAPIS_BLOCK) && checkAll(LIVINGROCK_BLOCKS, ModBlocks.livingrock);
|
||||
}
|
||||
|
||||
boolean checkAll(BlockPos[] relPositions, Block block) {
|
||||
private boolean checkAll(BlockPos[] relPositions, Block block) {
|
||||
for (BlockPos position : relPositions) {
|
||||
if(!checkPlatform(position.getX(), position.getZ(), block))
|
||||
return false;
|
||||
@@ -157,13 +166,13 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean checkPlatform(int xOff, int zOff, Block block) {
|
||||
private boolean checkPlatform(int xOff, int zOff, Block block) {
|
||||
return world.getBlockState(pos.add(xOff, -1, zOff)).getBlock() == block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_MANA, mana);
|
||||
cmp.putInt(TAG_MANA, mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,12 +10,21 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileTeruTeruBozu extends TileMod implements ITickable {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TERU_TERU_BOZU)
|
||||
public static TileEntityType<TileTeruTeruBozu> TYPE;
|
||||
private boolean wasRaining = false;
|
||||
|
||||
public boolean wasRaining = false;
|
||||
public TileTeruTeruBozu() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
@@ -10,10 +10,20 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileTinyPlanet extends TileMod implements ITickable {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_PLANET)
|
||||
public static TileEntityType<TileTinyPlanet> TYPE;
|
||||
|
||||
public TileTinyPlanet() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
@@ -23,19 +24,26 @@ import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileTinyPotato extends TileSimpleInventory implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_POTATO)
|
||||
public static TileEntityType<TileTinyPotato> TYPE;
|
||||
private static final String TAG_NAME = "name";
|
||||
|
||||
public int jumpTicks = 0;
|
||||
public ITextComponent name = new TextComponentString("");
|
||||
public int nextDoIt = 0;
|
||||
private int nextDoIt = 0;
|
||||
|
||||
public TileTinyPotato() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void interact(EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side) {
|
||||
int index = side.getIndex();
|
||||
@@ -67,7 +75,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickable {
|
||||
|
||||
for(int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack stackAt = getItemHandler().getStackInSlot(i);
|
||||
if(!stackAt.isEmpty() && stackAt.getItem() == Item.getItemFromBlock(ModBlocks.tinyPotato)) {
|
||||
if(!stackAt.isEmpty() && stackAt.getItem() == ModBlocks.tinyPotato.asItem()) {
|
||||
player.sendMessage(new TextComponentString("Don't talk to me or my son ever again."));
|
||||
return;
|
||||
}
|
||||
@@ -77,7 +85,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickable {
|
||||
}
|
||||
}
|
||||
|
||||
public void jump() {
|
||||
private void jump() {
|
||||
if(jumpTicks == 0)
|
||||
jumpTicks = 20;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,16 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.corporea;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
|
||||
public abstract class TileCorporeaBase extends TileSimpleInventory {
|
||||
public TileCorporeaBase(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
// These TE's only extend TileSimpleInventory to give sparks an inventory to attach to
|
||||
// TODO make sparks able to detect corporea blocks and not require them to have an inventory
|
||||
@Override
|
||||
|
||||
+14
-7
@@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -24,30 +25,35 @@ import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaRequestor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_CRYSTAL_CUBE)
|
||||
public static TileEntityType<TileCorporeaCrystalCube> TYPE;
|
||||
private static final String TAG_REQUEST_TARGET = "requestTarget";
|
||||
private static final String TAG_ITEM_COUNT = "itemCount";
|
||||
|
||||
private static final double LOG_2 = Math.log(2);
|
||||
|
||||
ItemStack requestTarget = ItemStack.EMPTY;
|
||||
int itemCount = 0;
|
||||
int ticks = 0;
|
||||
int compValue = 0;
|
||||
private ItemStack requestTarget = ItemStack.EMPTY;
|
||||
private int itemCount = 0;
|
||||
private int ticks = 0;
|
||||
private int compValue = 0;
|
||||
|
||||
private final IAnimationStateMachine asm;
|
||||
private final LazyOptional<IAnimationStateMachine> asmCap;
|
||||
|
||||
public TileCorporeaCrystalCube() {
|
||||
super(TYPE);
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) {
|
||||
asm = ModelLoaderRegistry.loadASM(new ResourceLocation("botania", "asms/block/corporeacrystalcube.json"), ImmutableMap.of());
|
||||
asmCap = LazyOptional.of(() -> asm);
|
||||
@@ -127,8 +133,8 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(!requestTarget.isEmpty())
|
||||
cmp = requestTarget.write(cmp);
|
||||
par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp);
|
||||
par1nbtTagCompound.setInt(TAG_ITEM_COUNT, itemCount);
|
||||
par1nbtTagCompound.put(TAG_REQUEST_TARGET, cmp);
|
||||
par1nbtTagCompound.putInt(TAG_ITEM_COUNT, itemCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,6 +172,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
|
||||
if(cap == CapabilityAnimation.ANIMATION_CAPABILITY) {
|
||||
return asmCap.cast();
|
||||
|
||||
@@ -14,19 +14,29 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaRequestor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaRequestor {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_FUNNEL)
|
||||
public static TileEntityType<TileCorporeaFunnel> TYPE;
|
||||
|
||||
public TileCorporeaFunnel() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void doRequest() {
|
||||
ICorporeaSpark spark = getSpark();
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -26,6 +27,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ServerChatEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.CorporeaIndexRequestEvent;
|
||||
@@ -35,6 +37,7 @@ import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.common.advancements.CorporeaRequestTrigger;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -48,7 +51,8 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequestor, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_INDEX)
|
||||
public static TileEntityType<TileCorporeaIndex> TYPE;
|
||||
public static final double RADIUS = 2.5;
|
||||
|
||||
private static InputHandler input;
|
||||
@@ -166,6 +170,10 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
|
||||
public float closeby = 0F;
|
||||
public boolean hasCloseby;
|
||||
|
||||
public TileCorporeaIndex() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
double x = pos.getX() + 0.5;
|
||||
@@ -220,7 +228,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
|
||||
}
|
||||
|
||||
public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) {
|
||||
return player.dimension == index.world.getDimension().getId() && MathHelper.pointDistancePlane(index.getPos().getX() + 0.5, index.getPos().getZ() + 0.5, player.posX, player.posZ) < RADIUS && Math.abs(index.getPos().getY() + 0.5 - player.posY + (player.world.isRemote ? 0 : 1.6)) < 5;
|
||||
return player.dimension == index.world.getDimension().getType() && MathHelper.pointDistancePlane(index.getPos().getX() + 0.5, index.getPos().getZ() + 0.5, player.posX, player.posZ) < RADIUS && Math.abs(index.getPos().getY() + 0.5 - player.posY + (player.world.isRemote ? 0 : 1.6)) < 5;
|
||||
}
|
||||
|
||||
public static void addPattern(String pattern, IRegexStacker stacker) {
|
||||
@@ -281,7 +289,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
|
||||
if(name.equals("this")) {
|
||||
ItemStack stack = event.getPlayer().getHeldItemMainhand();
|
||||
if(!stack.isEmpty())
|
||||
name = stack.getDisplayName().toLowerCase().trim();
|
||||
name = stack.getDisplayName().getString().toLowerCase().trim();
|
||||
}
|
||||
|
||||
CorporeaIndexRequestEvent indexReqEvent = new CorporeaIndexRequestEvent(event.getPlayer(), name, count, spark);
|
||||
|
||||
@@ -13,18 +13,28 @@ package vazkii.botania.common.block.tile.corporea;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaInterceptor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.api.corporea.InvWithLocation;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorporeaInterceptor {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_INTERCEPTOR)
|
||||
public static TileEntityType<TileCorporeaInterceptor> TYPE;
|
||||
|
||||
public TileCorporeaInterceptor() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptRequest(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List<ItemStack> stacks, List<InvWithLocation> inventories, boolean doit) {}
|
||||
|
||||
@@ -12,15 +12,20 @@ package vazkii.botania.common.block.tile.corporea;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaRequestor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.api.corporea.InvWithLocation;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileCorporeaRetainer extends TileMod {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_RETAINER)
|
||||
public static TileEntityType<TileCorporeaRetainer> TYPE;
|
||||
private static final String TAG_PENDING_REQUEST = "pendingRequest";
|
||||
private static final String TAG_REQUEST_X = "requestX";
|
||||
private static final String TAG_REQUEST_Y = "requestY";
|
||||
@@ -34,11 +39,15 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
private static final int REQUEST_ITEMSTACK = 1;
|
||||
private static final int REQUEST_STRING = 2;
|
||||
|
||||
boolean pendingRequest = false;
|
||||
BlockPos requestPos = BlockPos.ORIGIN;
|
||||
Object request;
|
||||
int requestCount;
|
||||
int compValue;
|
||||
private boolean pendingRequest = false;
|
||||
private BlockPos requestPos = BlockPos.ORIGIN;
|
||||
private Object request;
|
||||
private int requestCount;
|
||||
private int compValue;
|
||||
|
||||
public TileCorporeaRetainer() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void setPendingRequest(BlockPos pos, Object request, int requestCount) {
|
||||
if(pendingRequest)
|
||||
@@ -81,27 +90,27 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
super.writePacketNBT(cmp);
|
||||
|
||||
cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest);
|
||||
cmp.setInt(TAG_REQUEST_X, requestPos.getX());
|
||||
cmp.setInt(TAG_REQUEST_Y, requestPos.getY());
|
||||
cmp.setInt(TAG_REQUEST_Z, requestPos.getZ());
|
||||
cmp.putBoolean(TAG_PENDING_REQUEST, pendingRequest);
|
||||
cmp.putInt(TAG_REQUEST_X, requestPos.getX());
|
||||
cmp.putInt(TAG_REQUEST_Y, requestPos.getY());
|
||||
cmp.putInt(TAG_REQUEST_Z, requestPos.getZ());
|
||||
|
||||
int reqType = REQUEST_NULL;
|
||||
if(request != null)
|
||||
reqType = request instanceof String ? REQUEST_STRING : REQUEST_ITEMSTACK;
|
||||
cmp.setInt(TAG_REQUEST_TYPE, reqType);
|
||||
cmp.putInt(TAG_REQUEST_TYPE, reqType);
|
||||
|
||||
switch (reqType) {
|
||||
case REQUEST_STRING:
|
||||
cmp.setString(TAG_REQUEST_CONTENTS, (String) request);
|
||||
cmp.putString(TAG_REQUEST_CONTENTS, (String) request);
|
||||
break;
|
||||
case REQUEST_ITEMSTACK:
|
||||
NBTTagCompound cmp1 = ((ItemStack) request).write(new NBTTagCompound());
|
||||
cmp.setTag(TAG_REQUEST_STACK, cmp1);
|
||||
cmp.put(TAG_REQUEST_STACK, cmp1);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
cmp.setInt(TAG_REQUEST_COUNT, requestCount);
|
||||
cmp.putInt(TAG_REQUEST_COUNT, requestCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,27 +12,37 @@ package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Particles;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileExoflame;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileBellows extends TileMod implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BELLOWS)
|
||||
public static TileEntityType<TileBellows> TYPE;
|
||||
private static final String TAG_ACTIVE = "active";
|
||||
|
||||
public float movePos;
|
||||
public boolean active = false;
|
||||
public float moving = 0F;
|
||||
|
||||
public TileBellows() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void interact() {
|
||||
if(moving == 0F)
|
||||
setActive(true);
|
||||
@@ -46,7 +56,7 @@ public class TileBellows extends TileMod implements ITickable {
|
||||
TilePool pool = (TilePool) tile;
|
||||
boolean transfer = pool.isDoingTransfer;
|
||||
if(transfer) {
|
||||
if(!active && pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2)
|
||||
if(pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2)
|
||||
setActive(true);
|
||||
disable = false;
|
||||
}
|
||||
@@ -68,34 +78,21 @@ public class TileBellows extends TileMod implements ITickable {
|
||||
furnace.setField(0, Math.max(0, furnace.getField(0) - 10)); // burnTime
|
||||
}
|
||||
|
||||
if(furnace.hasWorld() && furnace.getBlockType() == Blocks.LIT_FURNACE) {
|
||||
// Copypasta from BlockFurnace
|
||||
EnumFacing enumfacing = world.getBlockState(furnace.getPos()).getValue(BlockFurnace.FACING);
|
||||
double d0 = pos.getX() + 0.5D;
|
||||
double d1 = pos.getY() + world.rand.nextDouble() * 6.0D / 16.0D;
|
||||
double d2 = pos.getZ() + 0.5D;
|
||||
if(furnace.hasWorld() && furnace.getBlockState().get(BlockFurnace.LIT)) {
|
||||
// [VanillaCopy] BlockFurnace
|
||||
double d0 = (double)pos.getX() + 0.5D;
|
||||
double d1 = (double)pos.getY();
|
||||
double d2 = (double)pos.getZ() + 0.5D;
|
||||
|
||||
EnumFacing enumfacing = furnace.getBlockState().get(BlockFurnace.FACING);
|
||||
EnumFacing.Axis enumfacing$axis = enumfacing.getAxis();
|
||||
double d3 = 0.52D;
|
||||
double d4 = world.rand.nextDouble() * 0.6D - 0.3D;
|
||||
|
||||
switch (enumfacing)
|
||||
{
|
||||
case WEST:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case EAST:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case NORTH:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case SOUTH:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D);
|
||||
default: break;
|
||||
}
|
||||
double d5 = enumfacing$axis == EnumFacing.Axis.X ? (double)enumfacing.getXOffset() * 0.52D : d4;
|
||||
double d6 = world.rand.nextDouble() * 6.0D / 16.0D;
|
||||
double d7 = enumfacing$axis == EnumFacing.Axis.Z ? (double)enumfacing.getZOffset() * 0.52D : d4;
|
||||
world.addParticle(Particles.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
|
||||
world.addParticle(Particles.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +122,7 @@ public class TileBellows extends TileMod implements ITickable {
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setBoolean(TAG_ACTIVE, active);
|
||||
cmp.putBoolean(TAG_ACTIVE, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,31 +11,40 @@
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileDistributor extends TileMod implements IManaReceiver, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.DISTRIBUTOR)
|
||||
public static TileEntityType<TileDistributor> TYPE;
|
||||
private final List<IManaReceiver> validPools = new ArrayList<>();
|
||||
|
||||
public TileDistributor() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
validPools.clear();
|
||||
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
|
||||
for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) {
|
||||
BlockPos pos = this.pos.offset(dir);
|
||||
if(world.isBlockLoaded(pos)) {
|
||||
TileEntity tileAt = world.getTileEntity(pos);
|
||||
if(tileAt instanceof IManaPool && !tileAt.isInvalid()) {
|
||||
if(tileAt instanceof IManaPool && !tileAt.isRemoved()) {
|
||||
IManaReceiver receiver = (IManaReceiver) tileAt;
|
||||
if(!receiver.isFull())
|
||||
validPools.add(receiver);
|
||||
|
||||
@@ -12,21 +12,31 @@ package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileManaDetector extends TileMod implements ITickable {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_DETECTOR)
|
||||
public static TileEntityType<TileManaDetector> TYPE;
|
||||
|
||||
public TileManaDetector() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
boolean state = world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
|
||||
public void tick() {
|
||||
boolean state = world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
|
||||
boolean expectedState = world.getEntitiesWithinAABB(EntityThrowable.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)), Predicates.instanceOf(IManaBurst.class)).size() != 0;
|
||||
if(state != expectedState && !world.isRemote)
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, expectedState), 1 | 2);
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, expectedState));
|
||||
|
||||
if(expectedState)
|
||||
for(int i = 0; i < 4; i++)
|
||||
|
||||
@@ -10,11 +10,21 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.mana.IClientManaHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileManaVoid extends TileMod implements IClientManaHandler {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_VOID)
|
||||
public static TileEntityType<TileManaVoid> TYPE;
|
||||
|
||||
public TileManaVoid() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
@@ -34,6 +35,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
@@ -60,6 +62,8 @@ import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.item.ItemManaTablet;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
@@ -67,10 +71,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAttachable, IThrottledPacket, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.POOL)
|
||||
public static TileEntityType<TilePool> TYPE;
|
||||
public static final Color PARTICLE_COLOR = new Color(0x00C6FF);
|
||||
public static final int MAX_MANA = 1000000;
|
||||
public static final int MAX_MANA_DILLUTED = 10000;
|
||||
private static final int MAX_MANA_DILLUTED = 10000;
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
private static final String TAG_KNOWN_MANA = "knownMana";
|
||||
@@ -105,13 +110,8 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
private int ticks = 0;
|
||||
private boolean sendPacket = false;
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState) {
|
||||
if(oldState.getBlock() != newState.getBlock())
|
||||
return true;
|
||||
if(!(oldState.getBlock() instanceof BlockPool) || !(newState.getBlock() instanceof BlockPool))
|
||||
return true;
|
||||
return false;
|
||||
public TilePool() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,14 +131,14 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
public void remove() {
|
||||
super.remove();
|
||||
ManaNetworkEvent.removePool(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
public void onChunkUnloaded() {
|
||||
super.onChunkUnloaded();
|
||||
ManaNetworkEvent.removePool(this);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
}
|
||||
|
||||
public boolean collideEntityItem(EntityItem item) {
|
||||
if(world.isRemote || item.isDead || item.getItem().isEmpty())
|
||||
if(world.isRemote || !item.isAlive() || item.getItem().isEmpty())
|
||||
return false;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
@@ -209,7 +209,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
soundTicks = 6;
|
||||
}
|
||||
|
||||
world.addBlockEvent(getPos(), getBlockType(), CRAFT_EFFECT_EVENT, 0);
|
||||
world.addBlockEvent(getPos(), getBlockState().getBlock(), CRAFT_EFFECT_EVENT, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -245,11 +245,11 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if(manaCap == -1)
|
||||
manaCap = ((BlockPool) getBlockType()).variant == BlockPool.Variant.DILUTED ? MAX_MANA_DILLUTED : MAX_MANA;
|
||||
manaCap = ((BlockPool) getBlockState().getBlock()).variant == BlockPool.Variant.DILUTED ? MAX_MANA_DILLUTED : MAX_MANA;
|
||||
|
||||
if(!ManaNetworkHandler.instance.isPoolIn(this) && !isInvalid())
|
||||
if(!ManaNetworkHandler.instance.isPoolIn(this) && !isRemoved())
|
||||
ManaNetworkEvent.addPool(this);
|
||||
|
||||
if(world.isRemote) {
|
||||
@@ -273,7 +273,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
|
||||
for(EntityItem item : items) {
|
||||
if(item.isDead)
|
||||
if(!item.isAlive())
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
@@ -284,9 +284,9 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
int bellowCount = 0;
|
||||
if(outputting)
|
||||
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
|
||||
for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) {
|
||||
TileEntity tile = world.getTileEntity(pos.offset(dir));
|
||||
if(tile != null && tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this)
|
||||
if(tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this)
|
||||
bellowCount++;
|
||||
}
|
||||
int transfRate = 1000 * (bellowCount + 1);
|
||||
@@ -313,7 +313,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
if(didSomething) {
|
||||
if(ConfigHandler.chargingAnimationEnabled && world.rand.nextInt(20) == 0) {
|
||||
world.addBlockEvent(getPos(), getBlockType(), CHARGE_EFFECT_EVENT, outputting ? 1 : 0);
|
||||
world.addBlockEvent(getPos(), getBlockState().getBlock(), CHARGE_EFFECT_EVENT, outputting ? 1 : 0);
|
||||
}
|
||||
isDoingTransfer = outputting;
|
||||
}
|
||||
@@ -334,17 +334,17 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_MANA, mana);
|
||||
cmp.setBoolean(TAG_OUTPUTTING, outputting);
|
||||
cmp.setInt(TAG_COLOR, color.getId());
|
||||
cmp.putInt(TAG_MANA, mana);
|
||||
cmp.putBoolean(TAG_OUTPUTTING, outputting);
|
||||
cmp.putInt(TAG_COLOR, color.getId());
|
||||
|
||||
cmp.setInt(TAG_MANA_CAP, manaCap);
|
||||
cmp.setBoolean(TAG_CAN_ACCEPT, canAccept);
|
||||
cmp.setBoolean(TAG_CAN_SPARE, canSpare);
|
||||
cmp.setBoolean(TAG_FRAGILE, fragile);
|
||||
cmp.putInt(TAG_MANA_CAP, manaCap);
|
||||
cmp.putBoolean(TAG_CAN_ACCEPT, canAccept);
|
||||
cmp.putBoolean(TAG_CAN_SPARE, canSpare);
|
||||
cmp.putBoolean(TAG_FRAGILE, fragile);
|
||||
|
||||
cmp.setString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.setString(TAG_OUTPUT_KEY, outputKey);
|
||||
cmp.putString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.putString(TAG_OUTPUT_KEY, outputKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,20 +353,20 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
outputting = cmp.getBoolean(TAG_OUTPUTTING);
|
||||
color = EnumDyeColor.byId(cmp.getInt(TAG_COLOR));
|
||||
|
||||
if(cmp.hasKey(TAG_MANA_CAP))
|
||||
if(cmp.contains(TAG_MANA_CAP))
|
||||
manaCap = cmp.getInt(TAG_MANA_CAP);
|
||||
if(cmp.hasKey(TAG_CAN_ACCEPT))
|
||||
if(cmp.contains(TAG_CAN_ACCEPT))
|
||||
canAccept = cmp.getBoolean(TAG_CAN_ACCEPT);
|
||||
if(cmp.hasKey(TAG_CAN_SPARE))
|
||||
if(cmp.contains(TAG_CAN_SPARE))
|
||||
canSpare = cmp.getBoolean(TAG_CAN_SPARE);
|
||||
fragile = cmp.getBoolean(TAG_FRAGILE);
|
||||
|
||||
if(cmp.hasKey(TAG_INPUT_KEY))
|
||||
if(cmp.contains(TAG_INPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_INPUT_KEY);
|
||||
if(cmp.hasKey(TAG_OUTPUT_KEY))
|
||||
if(cmp.contains(TAG_OUTPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_OUTPUT_KEY);
|
||||
|
||||
if(cmp.hasKey(TAG_KNOWN_MANA))
|
||||
if(cmp.contains(TAG_KNOWN_MANA))
|
||||
knownMana = cmp.getInt(TAG_KNOWN_MANA);
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
if(!world.isRemote) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writePacketNBT(nbttagcompound);
|
||||
nbttagcompound.setInt(TAG_KNOWN_MANA, getCurrentMana());
|
||||
nbttagcompound.putInt(TAG_KNOWN_MANA, getCurrentMana());
|
||||
if(player instanceof EntityPlayerMP)
|
||||
((EntityPlayerMP) player).connection.sendPacket(new SPacketUpdateTileEntity(pos, -999, nbttagcompound));
|
||||
}
|
||||
@@ -434,8 +434,8 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
if (getBlockType() instanceof BlockPool) {
|
||||
return ((BlockPool) getBlockType()).variant == BlockPool.Variant.CREATIVE ? MAX_MANA : mana;
|
||||
if (getBlockState().getBlock() instanceof BlockPool) {
|
||||
return ((BlockPool) getBlockState().getBlock()).variant == BlockPool.Variant.CREATIVE ? MAX_MANA : mana;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
@@ -19,14 +21,22 @@ import vazkii.botania.api.mana.ILens;
|
||||
import vazkii.botania.api.mana.ITinyPlanetExcempt;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TilePrism extends TileSimpleInventory {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PRISM)
|
||||
public static TileEntityType<TilePrism> TYPE;
|
||||
|
||||
public TilePrism() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void onBurstCollision(IManaBurst burst) {
|
||||
ItemStack lens = itemHandler.getStackInSlot(0);
|
||||
boolean active = !world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
|
||||
boolean active = !world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
|
||||
boolean valid = !lens.isEmpty() && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens));
|
||||
|
||||
if(active) {
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.init.Particles;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
@@ -21,22 +22,27 @@ import net.minecraftforge.common.animation.TimeValues;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TilePump extends TileMod implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PUMP)
|
||||
public static TileEntityType<TilePump> TYPE;
|
||||
private static final String TAG_ACTIVE = "active";
|
||||
|
||||
public float innerRingPos;
|
||||
private float innerRingPos;
|
||||
public boolean active = false;
|
||||
public boolean hasCart = false;
|
||||
public boolean hasCartOnTop = false;
|
||||
public float moving = 0F;
|
||||
private float moving = 0F;
|
||||
|
||||
public int comparator;
|
||||
public boolean hasRedstone = false;
|
||||
@@ -44,34 +50,31 @@ public class TilePump extends TileMod implements ITickable {
|
||||
|
||||
private final TimeValues.VariableValue move;
|
||||
private final IAnimationStateMachine asm;
|
||||
private final LazyOptional<IAnimationStateMachine> asmCap;
|
||||
|
||||
public TilePump() {
|
||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||
super(TYPE);
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) {
|
||||
move = new TimeValues.VariableValue(0);
|
||||
asm = ModelLoaderRegistry.loadASM(new ResourceLocation("botania", "asms/block/pump.json"), ImmutableMap.of("move", move));
|
||||
asmCap = LazyOptional.of(() -> asm);
|
||||
} else {
|
||||
move = null;
|
||||
asm = null;
|
||||
asmCap = LazyOptional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> cap, EnumFacing side) {
|
||||
return cap == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(cap, side);
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.orEmpty(cap, asmCap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
|
||||
if (cap == CapabilityAnimation.ANIMATION_CAPABILITY) {
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
hasRedstone = false;
|
||||
for(EnumFacing dir : EnumFacing.VALUES) {
|
||||
for(EnumFacing dir : EnumFacing.BY_INDEX) {
|
||||
int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
|
||||
if(redstoneSide > 0) {
|
||||
hasRedstone = true;
|
||||
@@ -91,7 +94,7 @@ public class TilePump extends TileMod implements ITickable {
|
||||
innerRingPos = Math.min(max, innerRingPos);
|
||||
moving = 0F;
|
||||
for(int x = 0; x < 2; x++)
|
||||
world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, getPos().getX() + Math.random(), getPos().getY() + Math.random(), getPos().getZ() + Math.random(), 0, 0, 0);
|
||||
world.addParticle(Particles.SMOKE, getPos().getX() + Math.random(), getPos().getY() + Math.random(), getPos().getZ() + Math.random(), 0, 0, 0);
|
||||
}
|
||||
} else if(innerRingPos > min) {
|
||||
innerRingPos -= incr * 2;
|
||||
@@ -122,7 +125,7 @@ public class TilePump extends TileMod implements ITickable {
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setBoolean(TAG_ACTIVE, active);
|
||||
cmp.putBoolean(TAG_ACTIVE, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,25 +12,31 @@ package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RF_GENERATOR)
|
||||
public static TileEntityType<TileRFGenerator> TYPE;
|
||||
private static final int MANA_TO_FE = 10;
|
||||
private static final int MAX_ENERGY = 1280 * MANA_TO_FE;
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
int energy = 0;
|
||||
private int energy = 0;
|
||||
|
||||
private final IEnergyStorage energyHandler = new IEnergyStorage() {
|
||||
@Override
|
||||
@@ -50,22 +56,22 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable
|
||||
@Override public int receiveEnergy(int maxReceive, boolean simulate) { return 0; }
|
||||
@Override public boolean canReceive() { return false; }
|
||||
};
|
||||
private final LazyOptional<IEnergyStorage> energyCap = LazyOptional.of(() -> energyHandler);
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> cap, @Nullable EnumFacing side) {
|
||||
return cap == CapabilityEnergy.ENERGY || super.hasCapability(cap, side);
|
||||
public TileRFGenerator() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
|
||||
if(cap == CapabilityEnergy.ENERGY) {
|
||||
return CapabilityEnergy.ENERGY.cast(energyHandler);
|
||||
return energyCap.cast();
|
||||
} else return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if(!world.isRemote) {
|
||||
int transfer = Math.min(energy, 160 * MANA_TO_FE);
|
||||
energy -= transfer;
|
||||
@@ -74,7 +80,7 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable
|
||||
}
|
||||
|
||||
private int transmitEnergy(int energy) {
|
||||
for(EnumFacing e : EnumFacing.VALUES) {
|
||||
for(EnumFacing e : EnumFacing.BY_INDEX) {
|
||||
BlockPos neighbor = getPos().offset(e);
|
||||
if(!world.isBlockLoaded(neighbor))
|
||||
continue;
|
||||
@@ -83,16 +89,17 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable
|
||||
if(te == null)
|
||||
continue;
|
||||
|
||||
IEnergyStorage storage = null;
|
||||
LazyOptional<IEnergyStorage> storage = LazyOptional.empty();
|
||||
|
||||
if(te.hasCapability(CapabilityEnergy.ENERGY, e.getOpposite())) {
|
||||
if(te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite()).isPresent()) {
|
||||
storage = te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite());
|
||||
} else if(te.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
||||
} else if(te.getCapability(CapabilityEnergy.ENERGY, null).isPresent()) {
|
||||
storage = te.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
}
|
||||
|
||||
if(storage != null) {
|
||||
energy -= storage.receiveEnergy(energy, false);
|
||||
|
||||
if(storage.isPresent()) {
|
||||
energy -= storage.orElseThrow(NullPointerException::new).receiveEnergy(energy, false);
|
||||
|
||||
if (energy <= 0)
|
||||
return 0;
|
||||
@@ -124,12 +131,12 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_MANA, energy);
|
||||
cmp.putInt(TAG_MANA, energy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketNBT(NBTTagCompound cmp) {
|
||||
energy = cmp.getInteger(TAG_MANA);
|
||||
energy = cmp.getInt(TAG_MANA);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,6 @@ package vazkii.botania.common.block.tile.mana;
|
||||
import com.google.common.base.Predicates;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -25,6 +24,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.Mirror;
|
||||
@@ -33,11 +33,14 @@ import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
@@ -65,13 +68,17 @@ import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.entity.EntityManaBurst;
|
||||
import vazkii.botania.common.entity.EntityManaBurst.PositionProperties;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IDirectioned, ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPREADER)
|
||||
public static TileEntityType<TileSpreader> TYPE;
|
||||
private static final int MAX_MANA = 1000;
|
||||
private static final int ULTRA_MAX_MANA = 6400;
|
||||
private static final int TICKS_ALLOWED_WITHOUT_PINGBACK = 20;
|
||||
@@ -109,16 +116,16 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
private static final String TAG_FORCED_GRAVITY = "mmForcedGravity";
|
||||
private static final String TAG_FORCED_VELOCITY_MULTIPLIER = "mmForcedVelocityMultiplier";
|
||||
|
||||
boolean mapmakerOverride = false;
|
||||
int mmForcedColor = 0x20FF20;
|
||||
int mmForcedManaPayload = 160;
|
||||
int mmForcedTicksBeforeManaLoss = 60;
|
||||
float mmForcedManaLossPerTick = 4F;
|
||||
float mmForcedGravity = 0F;
|
||||
float mmForcedVelocityMultiplier = 1F;
|
||||
private boolean mapmakerOverride = false;
|
||||
private int mmForcedColor = 0x20FF20;
|
||||
private int mmForcedManaPayload = 160;
|
||||
private int mmForcedTicksBeforeManaLoss = 60;
|
||||
private float mmForcedManaLossPerTick = 4F;
|
||||
private float mmForcedGravity = 0F;
|
||||
private float mmForcedVelocityMultiplier = 1F;
|
||||
|
||||
String inputKey = "";
|
||||
final String outputKey = "";
|
||||
private String inputKey = "";
|
||||
private final String outputKey = "";
|
||||
|
||||
// End Map Maker Tags
|
||||
|
||||
@@ -129,17 +136,17 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
UUID identity;
|
||||
|
||||
int mana;
|
||||
int knownMana = -1;
|
||||
private int knownMana = -1;
|
||||
public float rotationX, rotationY;
|
||||
public int paddingColor = -1;
|
||||
|
||||
boolean requestsClientUpdate = false;
|
||||
boolean hasReceivedInitialPacket = false;
|
||||
private boolean requestsClientUpdate = false;
|
||||
private boolean hasReceivedInitialPacket = false;
|
||||
|
||||
IManaReceiver receiver = null;
|
||||
IManaReceiver receiverLastTick = null;
|
||||
private IManaReceiver receiver = null;
|
||||
private IManaReceiver receiverLastTick = null;
|
||||
|
||||
boolean redstoneLastTick = true;
|
||||
private boolean redstoneLastTick = true;
|
||||
public boolean canShootBurst = true;
|
||||
public int lastBurstDeathTick = -1;
|
||||
public int burstParticleTick = 0;
|
||||
@@ -149,8 +156,12 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
public double lastPingbackY = -1;
|
||||
public double lastPingbackZ = 0;
|
||||
|
||||
List<PositionProperties> lastTentativeBurst;
|
||||
boolean invalidTentativeBurst = false;
|
||||
private List<PositionProperties> lastTentativeBurst;
|
||||
private boolean invalidTentativeBurst = false;
|
||||
|
||||
public TileSpreader() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
@@ -163,28 +174,28 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
public void remove() {
|
||||
super.remove();
|
||||
ManaNetworkEvent.removeCollector(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
public void onChunkUnloaded() {
|
||||
super.onChunkUnloaded();
|
||||
ManaNetworkEvent.removeCollector(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this);
|
||||
boolean wasInNetwork = inNetwork;
|
||||
if(!inNetwork && !isInvalid()) {
|
||||
if(!inNetwork && !isRemoved()) {
|
||||
ManaNetworkEvent.addCollector(this);
|
||||
}
|
||||
|
||||
boolean redstone = false;
|
||||
|
||||
for(EnumFacing dir : EnumFacing.VALUES) {
|
||||
for(EnumFacing dir : EnumFacing.BY_INDEX) {
|
||||
TileEntity tileAt = world.getTileEntity(pos.offset(dir));
|
||||
if(world.isBlockLoaded(pos.offset(dir), false) && tileAt instanceof IManaPool) {
|
||||
IManaPool pool = (IManaPool) tileAt;
|
||||
@@ -267,36 +278,36 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
super.writePacketNBT(cmp);
|
||||
|
||||
UUID identity = getIdentifier();
|
||||
cmp.setBoolean(TAG_HAS_IDENTITY, true);
|
||||
cmp.setLong(TAG_UUID_MOST, identity.getMostSignificantBits());
|
||||
cmp.setLong(TAG_UUID_LEAST, identity.getLeastSignificantBits());
|
||||
cmp.putBoolean(TAG_HAS_IDENTITY, true);
|
||||
cmp.putLong(TAG_UUID_MOST, identity.getMostSignificantBits());
|
||||
cmp.putLong(TAG_UUID_LEAST, identity.getLeastSignificantBits());
|
||||
|
||||
cmp.setInteger(TAG_MANA, mana);
|
||||
cmp.setFloat(TAG_ROTATION_X, rotationX);
|
||||
cmp.setFloat(TAG_ROTATION_Y, rotationY);
|
||||
cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate);
|
||||
cmp.setInteger(TAG_PADDING_COLOR, paddingColor);
|
||||
cmp.setBoolean(TAG_CAN_SHOOT_BURST, canShootBurst);
|
||||
cmp.putInt(TAG_MANA, mana);
|
||||
cmp.putFloat(TAG_ROTATION_X, rotationX);
|
||||
cmp.putFloat(TAG_ROTATION_Y, rotationY);
|
||||
cmp.putBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate);
|
||||
cmp.putInt(TAG_PADDING_COLOR, paddingColor);
|
||||
cmp.putBoolean(TAG_CAN_SHOOT_BURST, canShootBurst);
|
||||
|
||||
cmp.setInteger(TAG_PINGBACK_TICKS, pingbackTicks);
|
||||
cmp.setDouble(TAG_LAST_PINGBACK_X, lastPingbackX);
|
||||
cmp.setDouble(TAG_LAST_PINGBACK_Y, lastPingbackY);
|
||||
cmp.setDouble(TAG_LAST_PINGBACK_Z, lastPingbackZ);
|
||||
cmp.putInt(TAG_PINGBACK_TICKS, pingbackTicks);
|
||||
cmp.putDouble(TAG_LAST_PINGBACK_X, lastPingbackX);
|
||||
cmp.putDouble(TAG_LAST_PINGBACK_Y, lastPingbackY);
|
||||
cmp.putDouble(TAG_LAST_PINGBACK_Z, lastPingbackZ);
|
||||
|
||||
cmp.setString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.setString(TAG_OUTPUT_KEY, outputKey);
|
||||
cmp.putString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.putString(TAG_OUTPUT_KEY, outputKey);
|
||||
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).getPos().getX());
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).getPos().getY());
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).getPos().getZ());
|
||||
cmp.putInt(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).getPos().getX());
|
||||
cmp.putInt(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).getPos().getY());
|
||||
cmp.putInt(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).getPos().getZ());
|
||||
|
||||
cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride);
|
||||
cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor);
|
||||
cmp.setInteger(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload);
|
||||
cmp.setInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS, mmForcedTicksBeforeManaLoss);
|
||||
cmp.setFloat(TAG_FORCED_MANA_LOSS_PER_TICK, mmForcedManaLossPerTick);
|
||||
cmp.setFloat(TAG_FORCED_GRAVITY, mmForcedGravity);
|
||||
cmp.setFloat(TAG_FORCED_VELOCITY_MULTIPLIER, mmForcedVelocityMultiplier);
|
||||
cmp.putBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride);
|
||||
cmp.putInt(TAG_FORCED_COLOR, mmForcedColor);
|
||||
cmp.putInt(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload);
|
||||
cmp.putInt(TAG_FORCED_TICKS_BEFORE_MANA_LOSS, mmForcedTicksBeforeManaLoss);
|
||||
cmp.putFloat(TAG_FORCED_MANA_LOSS_PER_TICK, mmForcedManaLossPerTick);
|
||||
cmp.putFloat(TAG_FORCED_GRAVITY, mmForcedGravity);
|
||||
cmp.putFloat(TAG_FORCED_VELOCITY_MULTIPLIER, mmForcedVelocityMultiplier);
|
||||
|
||||
requestsClientUpdate = false;
|
||||
}
|
||||
@@ -313,40 +324,40 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
this.identity = new UUID(most, least);
|
||||
} else getIdentifier();
|
||||
|
||||
mana = cmp.getInteger(TAG_MANA);
|
||||
mana = cmp.getInt(TAG_MANA);
|
||||
rotationX = cmp.getFloat(TAG_ROTATION_X);
|
||||
rotationY = cmp.getFloat(TAG_ROTATION_Y);
|
||||
requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE);
|
||||
|
||||
if(cmp.hasKey(TAG_INPUT_KEY))
|
||||
if(cmp.contains(TAG_INPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_INPUT_KEY);
|
||||
if(cmp.hasKey(TAG_OUTPUT_KEY))
|
||||
if(cmp.contains(TAG_OUTPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_OUTPUT_KEY);
|
||||
|
||||
mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE);
|
||||
mmForcedColor = cmp.getInteger(TAG_FORCED_COLOR);
|
||||
mmForcedManaPayload = cmp.getInteger(TAG_FORCED_MANA_PAYLOAD);
|
||||
mmForcedTicksBeforeManaLoss = cmp.getInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS);
|
||||
mmForcedColor = cmp.getInt(TAG_FORCED_COLOR);
|
||||
mmForcedManaPayload = cmp.getInt(TAG_FORCED_MANA_PAYLOAD);
|
||||
mmForcedTicksBeforeManaLoss = cmp.getInt(TAG_FORCED_TICKS_BEFORE_MANA_LOSS);
|
||||
mmForcedManaLossPerTick = cmp.getFloat(TAG_FORCED_MANA_LOSS_PER_TICK);
|
||||
mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY);
|
||||
mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER);
|
||||
|
||||
if(cmp.hasKey(TAG_KNOWN_MANA))
|
||||
knownMana = cmp.getInteger(TAG_KNOWN_MANA);
|
||||
if(cmp.hasKey(TAG_PADDING_COLOR))
|
||||
paddingColor = cmp.getInteger(TAG_PADDING_COLOR);
|
||||
if(cmp.hasKey(TAG_CAN_SHOOT_BURST))
|
||||
if(cmp.contains(TAG_KNOWN_MANA))
|
||||
knownMana = cmp.getInt(TAG_KNOWN_MANA);
|
||||
if(cmp.contains(TAG_PADDING_COLOR))
|
||||
paddingColor = cmp.getInt(TAG_PADDING_COLOR);
|
||||
if(cmp.contains(TAG_CAN_SHOOT_BURST))
|
||||
canShootBurst = cmp.getBoolean(TAG_CAN_SHOOT_BURST);
|
||||
|
||||
pingbackTicks = cmp.getInteger(TAG_PINGBACK_TICKS);
|
||||
pingbackTicks = cmp.getInt(TAG_PINGBACK_TICKS);
|
||||
lastPingbackX = cmp.getDouble(TAG_LAST_PINGBACK_X);
|
||||
lastPingbackY = cmp.getDouble(TAG_LAST_PINGBACK_Y);
|
||||
lastPingbackZ = cmp.getDouble(TAG_LAST_PINGBACK_Z);
|
||||
|
||||
if(requestsClientUpdate && world != null) {
|
||||
int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X);
|
||||
int y = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Y);
|
||||
int z = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Z);
|
||||
int x = cmp.getInt(TAG_FORCE_CLIENT_BINDING_X);
|
||||
int y = cmp.getInt(TAG_FORCE_CLIENT_BINDING_Y);
|
||||
int z = cmp.getInt(TAG_FORCE_CLIENT_BINDING_Z);
|
||||
if(y != -1) {
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if(tile instanceof IManaReceiver)
|
||||
@@ -377,13 +388,13 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
if(!world.isRemote) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writePacketNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger(TAG_KNOWN_MANA, mana);
|
||||
nbttagcompound.putInt(TAG_KNOWN_MANA, mana);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
((EntityPlayerMP) player).connection.sendPacket(new SPacketUpdateTileEntity(pos, -999, nbttagcompound));
|
||||
}
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.ding, SoundCategory.PLAYERS, 0.1F, 1);
|
||||
} else {
|
||||
RayTraceResult pos = raytraceFromEntity(world, player, true);
|
||||
RayTraceResult pos = rayTraceFromEntity(world, player, true);
|
||||
if(pos != null && pos.hitVec != null && !world.isRemote) {
|
||||
double x = pos.hitVec.x - getPos().getX() - 0.5;
|
||||
double y = pos.hitVec.y - getPos().getY() - 0.5;
|
||||
@@ -425,7 +436,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
return false;
|
||||
}
|
||||
|
||||
public void tryShootBurst() {
|
||||
private void tryShootBurst() {
|
||||
if((receiver != null || isRedstone()) && !invalidTentativeBurst) {
|
||||
if(canShootBurst && (isRedstone() || receiver.canRecieveManaFromBursts() && !receiver.isFull())) {
|
||||
EntityManaBurst burst = getBurst(false);
|
||||
@@ -445,17 +456,17 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
public boolean isRedstone() {
|
||||
updateContainingBlockInfo();
|
||||
return world == null ? staticRedstone : getBlockType() == ModBlocks.redstoneSpreader;
|
||||
return world == null ? staticRedstone : getBlockState().getBlock() == ModBlocks.redstoneSpreader;
|
||||
}
|
||||
|
||||
public boolean isDreamwood() {
|
||||
updateContainingBlockInfo();
|
||||
return world == null ? staticDreamwood : getBlockType() == ModBlocks.elvenSpreader;
|
||||
return world == null ? staticDreamwood : getBlockState().getBlock() == ModBlocks.elvenSpreader;
|
||||
}
|
||||
|
||||
public boolean isULTRA_SPREADER() {
|
||||
updateContainingBlockInfo();
|
||||
return world == null ? staticUltra : getBlockType() == ModBlocks.gaiaSpreader;
|
||||
return world == null ? staticUltra : getBlockState().getBlock() == ModBlocks.gaiaSpreader;
|
||||
}
|
||||
|
||||
public void checkForReceiver() {
|
||||
@@ -468,8 +479,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
fakeBurst.setScanBeam();
|
||||
TileEntity receiver = fakeBurst.getCollidedTile(true);
|
||||
|
||||
if(receiver != null
|
||||
&& receiver instanceof IManaReceiver
|
||||
if(receiver instanceof IManaReceiver
|
||||
&& receiver.hasWorld()
|
||||
&& receiver.getWorld().isBlockLoaded(receiver.getPos(), !receiver.getWorld().isRemote))
|
||||
this.receiver = (IManaReceiver) receiver;
|
||||
@@ -485,7 +495,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
return fakeBurst;
|
||||
}
|
||||
|
||||
public EntityManaBurst getBurst(boolean fake) {
|
||||
private EntityManaBurst getBurst(boolean fake) {
|
||||
EntityManaBurst burst = new EntityManaBurst(this, fake);
|
||||
|
||||
boolean dreamwood = isDreamwood();
|
||||
@@ -538,25 +548,23 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
}
|
||||
|
||||
// [VanillaCopy] Item.rayTrace
|
||||
protected RayTraceResult raytraceFromEntity(World worldIn, EntityPlayer playerIn, boolean useLiquids) {
|
||||
@Nullable
|
||||
protected static RayTraceResult rayTraceFromEntity(World worldIn, EntityPlayer playerIn, boolean useLiquids) {
|
||||
float f = playerIn.rotationPitch;
|
||||
float f1 = playerIn.rotationYaw;
|
||||
double d0 = playerIn.posX;
|
||||
double d1 = playerIn.posY + (double) playerIn.getEyeHeight();
|
||||
double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
|
||||
double d2 = playerIn.posZ;
|
||||
Vec3d vec3d = new Vec3d(d0, d1, d2);
|
||||
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI);
|
||||
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI);
|
||||
float f4 = -MathHelper.cos(-f * 0.017453292F);
|
||||
float f5 = MathHelper.sin(-f * 0.017453292F);
|
||||
float f2 = MathHelper.cos(-f1 * ((float)Math.PI / 180F) - (float)Math.PI);
|
||||
float f3 = MathHelper.sin(-f1 * ((float)Math.PI / 180F) - (float)Math.PI);
|
||||
float f4 = -MathHelper.cos(-f * ((float)Math.PI / 180F));
|
||||
float f5 = MathHelper.sin(-f * ((float)Math.PI / 180F));
|
||||
float f6 = f3 * f4;
|
||||
float f7 = f2 * f4;
|
||||
double d3 = 5.0D;
|
||||
if(playerIn instanceof net.minecraft.entity.player.EntityPlayerMP) {
|
||||
d3 = ((net.minecraft.entity.player.EntityPlayerMP) playerIn).interactionManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3d vec3d1 = vec3d.add((double) f6 * d3, (double) f5 * d3, (double) f7 * d3);
|
||||
return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
|
||||
double d3 = playerIn.getAttribute(EntityPlayer.REACH_DISTANCE).getValue();
|
||||
Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
|
||||
return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids ? RayTraceFluidMode.SOURCE_ONLY : RayTraceFluidMode.NEVER, false, false);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -584,7 +592,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
if(receiver != null) {
|
||||
TileEntity receiverTile = (TileEntity) receiver;
|
||||
ItemStack recieverStack = new ItemStack(world.getBlockState(receiverTile.getPos()).getBlock(), 1, receiverTile.getBlockMetadata());
|
||||
ItemStack recieverStack = new ItemStack(world.getBlockState(receiverTile.getPos()).getBlock());
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
if(!recieverStack.isEmpty()) {
|
||||
@@ -682,10 +690,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
Vector3 thisVec = Vector3.fromTileEntityCenter(this);
|
||||
Vector3 blockVec = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
|
||||
AxisAlignedBB axis = player.world.getBlockState(pos).getCollisionBoundingBox(player.world, pos);
|
||||
if(axis != null)
|
||||
axis = axis.offset(pos);
|
||||
else axis = new AxisAlignedBB(pos, pos.add(1, 1, 1));
|
||||
VoxelShape shape = player.world.getBlockState(pos).getShape(player.world, pos);
|
||||
AxisAlignedBB axis = shape.isEmpty() ? new AxisAlignedBB(pos) : shape.getBoundingBox();
|
||||
|
||||
if(!blockVec.isInside(axis))
|
||||
blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2);
|
||||
|
||||
@@ -16,22 +16,31 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileTurntable extends TileMod implements ITickable {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TURNTABLE)
|
||||
public static TileEntityType<TileTurntable> TYPE;
|
||||
private static final String TAG_SPEED = "speed";
|
||||
private static final String TAG_BACKWARDS = "backwards";
|
||||
|
||||
int speed = 1;
|
||||
boolean backwards = false;
|
||||
private int speed = 1;
|
||||
private boolean backwards = false;
|
||||
|
||||
public TileTurntable() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -58,8 +67,8 @@ public class TileTurntable extends TileMod implements ITickable {
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInt(TAG_SPEED, speed);
|
||||
cmp.setBoolean(TAG_BACKWARDS, backwards);
|
||||
cmp.putInt(TAG_SPEED, speed);
|
||||
cmp.putBoolean(TAG_BACKWARDS, backwards);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -28,6 +29,10 @@ public abstract class TileRedString extends TileMod implements ITileBound, ITick
|
||||
|
||||
private BlockPos binding;
|
||||
|
||||
public TileRedString(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
EnumFacing dir = getOrientation();
|
||||
|
||||
@@ -11,12 +11,21 @@
|
||||
package vazkii.botania.common.block.tile.string;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileRedStringComparator extends TileRedString {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_COMPARATOR)
|
||||
public static TileEntityType<TileRedStringComparator> TYPE;
|
||||
private int comparatorValue = 0;
|
||||
|
||||
public TileRedStringComparator() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
@@ -11,23 +11,37 @@
|
||||
package vazkii.botania.common.block.tile.string;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TileRedStringContainer extends TileRedString {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_CONTAINER)
|
||||
public static TileEntityType<TileRedStringContainer> TYPE;
|
||||
|
||||
public TileRedStringContainer() {
|
||||
this(TYPE);
|
||||
}
|
||||
|
||||
public TileRedStringContainer(TileEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
return tile != null
|
||||
&& Arrays.stream(EnumFacing.BY_INDEX)
|
||||
.anyMatch(e -> tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e));
|
||||
.anyMatch(e -> tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e).isPresent());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -12,14 +12,25 @@ package vazkii.botania.common.block.tile.string;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityDispenser;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileRedStringDispenser extends TileRedStringContainer {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_DISPENSER)
|
||||
public static TileEntityType<TileRedStringDispenser> TYPE;
|
||||
|
||||
public TileRedStringDispenser() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
return tile != null && tile instanceof TileEntityDispenser;
|
||||
return world.getTileEntity(pos) instanceof TileEntityDispenser;
|
||||
}
|
||||
|
||||
public void tickDispenser() {
|
||||
|
||||
@@ -12,25 +12,35 @@ package vazkii.botania.common.block.tile.string;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TileRedStringFertilizer extends TileRedString {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_FERTILIZER)
|
||||
public static TileEntityType<TileRedStringFertilizer> TYPE;
|
||||
|
||||
public TileRedStringFertilizer() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public boolean canGrow(IBlockReader world, boolean isClient) {
|
||||
BlockPos binding = getBinding();
|
||||
Block block = getBlockAtBinding();
|
||||
|
||||
return block instanceof IGrowable ? ((IGrowable) block).canGrow(world, binding, world.getBlockState(binding), isClient) : false;
|
||||
return block instanceof IGrowable && ((IGrowable) block).canGrow(world, binding, world.getBlockState(binding), isClient);
|
||||
}
|
||||
|
||||
public boolean canUseBonemeal(World world, Random rand) {
|
||||
BlockPos binding = getBinding();
|
||||
Block block = getBlockAtBinding();
|
||||
return block instanceof IGrowable ? ((IGrowable) block).canUseBonemeal(world, rand, binding, world.getBlockState(binding)) : false;
|
||||
return block instanceof IGrowable && ((IGrowable) block).canUseBonemeal(world, rand, binding, world.getBlockState(binding));
|
||||
}
|
||||
|
||||
public void grow(World world, Random rand) {
|
||||
|
||||
+11
-2
@@ -13,11 +13,15 @@ package vazkii.botania.common.block.tile.string;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -25,9 +29,14 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TileRedStringInterceptor extends TileRedString {
|
||||
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_INTERCEPTOR)
|
||||
public static TileEntityType<TileRedStringInterceptor> TYPE;
|
||||
private static final Set<TileRedStringInterceptor> interceptors = new HashSet<>();
|
||||
|
||||
public TileRedStringInterceptor() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
@@ -62,7 +71,7 @@ public class TileRedStringInterceptor extends TileRedString {
|
||||
BlockPos coords = inter.getBinding();
|
||||
if(coords != null && coords.equals(pos)) {
|
||||
Block block = inter.getBlockState().getBlock();
|
||||
world.setBlockState(inter.getPos(), world.getBlockState(inter.getPos()).with(BotaniaStateProps.POWERED, true), 1 | 2);
|
||||
world.setBlockState(inter.getPos(), world.getBlockState(inter.getPos()).with(BotaniaStateProps.POWERED, true));
|
||||
world.getPendingBlockTicks().scheduleTick(inter.getPos(), block, block.tickRate(world));
|
||||
did = true;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,20 @@ import net.minecraft.block.BlockDoublePlant;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.BlockMushroom;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.subtile.ISubTileContainer;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileRedStringRelay extends TileRedString {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_RELAY)
|
||||
public static TileEntityType<TileRedStringRelay> TYPE;
|
||||
|
||||
public TileRedStringRelay() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
|
||||
Reference in new issue
Block a user