A pass through TEs

This commit is contained in:
Vincent Lee committed 2019-02-05 00:40:10 -06:00
1 parent 1624603715
commit 5bf8fbcca6
43 files changed
+242 -256

No files matched your search

@@ -10,8 +10,8 @@
package vazkii.botania.api.corporea;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
/**
* CorporeaIndexRequestEvent is fired when a player attempts to request an item from a corporea index.
@@ -104,13 +104,13 @@ public class TileAlfPortal extends TileMod implements ITickable {
}
@Override
public void update() {
public void tick() {
IBlockState iBlockState = world.getBlockState(getPos());
if(iBlockState.getValue(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF) {
if(iBlockState.get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF) {
ticksOpen = 0;
return;
}
AlfPortalState state = iBlockState.getValue(BotaniaStateProps.ALFPORTAL_STATE);
AlfPortalState state = iBlockState.get(BotaniaStateProps.ALFPORTAL_STATE);
AlfPortalState newState = getValidState();
ticksOpen++;
@@ -131,7 +131,7 @@ public class TileAnimatedTorch extends TileMod implements ITickable {
}
@Override
public void update() {
public void tick() {
if(rotating) {
lastTickRotation = rotation;
rotation = (rotation + anglePerTick) % 360;
@@ -34,9 +34,9 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITic
int mana;
@Override
public void update() {
public void tick() {
enabled = true;
for(EnumFacing dir : EnumFacing.VALUES) {
for(EnumFacing dir : EnumFacing.BY_INDEX) {
int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
if(redstoneSide > 0) {
enabled = false;
@@ -58,16 +58,16 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITic
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
super.writePacketNBT(par1nbtTagCompound);
par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled);
par1nbtTagCompound.setInteger(TAG_TICKS_ELAPSED, ticksElapsed);
par1nbtTagCompound.setInteger(TAG_MANA, mana);
par1nbtTagCompound.setInt(TAG_TICKS_ELAPSED, ticksElapsed);
par1nbtTagCompound.setInt(TAG_MANA, mana);
}
@Override
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
super.readPacketNBT(par1nbtTagCompound);
enabled = par1nbtTagCompound.getBoolean(TAG_ENABLED);
ticksElapsed = par1nbtTagCompound.getInteger(TAG_TICKS_ELAPSED);
mana = par1nbtTagCompound.getInteger(TAG_MANA);
ticksElapsed = par1nbtTagCompound.getInt(TAG_TICKS_ELAPSED);
mana = par1nbtTagCompound.getInt(TAG_MANA);
}
@Override
@@ -112,7 +112,7 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITic
@Override
public EnumFacing getAvatarFacing() {
return world.getBlockState(getPos()).getValue(BotaniaStateProps.CARDINALS);
return world.getBlockState(getPos()).get(BotaniaStateProps.CARDINALS);
}
@Override
@@ -23,26 +23,26 @@ public class TileBifrost extends TileMod implements ITickable {
public int ticks = 0;
@Override
public void update() {
public void tick() {
if(!world.isRemote) {
if(ticks <= 0) {
world.setBlockToAir(pos);
world.removeBlock(pos);
} else ticks--;
}
}
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) {
NBTTagCompound ret = super.writeToNBT(par1nbtTagCompound);
ret.setInteger(TAG_TICKS, ticks);
public NBTTagCompound write(NBTTagCompound par1nbtTagCompound) {
NBTTagCompound ret = super.write(par1nbtTagCompound);
ret.setInt(TAG_TICKS, ticks);
return ret;
}
@Override
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
ticks = par1nbtTagCompound.getInteger(TAG_TICKS);
public void read(NBTTagCompound par1nbtTagCompound) {
super.read(par1nbtTagCompound);
ticks = par1nbtTagCompound.getInt(TAG_TICKS);
}
}
@@ -62,7 +62,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
stackToAdd.setCount(1);
itemHandler.setStackInSlot(i, stackToAdd);
if(player == null || !player.capabilities.isCreativeMode) {
if(player == null || !player.abilities.isCreativeMode) {
stack.shrink(1);
if(stack.isEmpty() && player != null)
player.setHeldItem(hand, ItemStack.EMPTY);
@@ -76,7 +76,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
for(RecipeBrew recipe : BotaniaAPI.brewRecipes)
if(recipe.matches(itemHandler) && !recipe.getOutput(itemHandler.getStackInSlot(0)).isEmpty()) {
this.recipe = recipe;
world.setBlockState(pos, ModBlocks.brewery.getDefaultState().withProperty(BotaniaStateProps.POWERED, true), 1 | 2);
world.setBlockState(pos, ModBlocks.brewery.getDefaultState().with(BotaniaStateProps.POWERED, true), 1 | 2);
}
}
@@ -84,12 +84,12 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
}
@Override
public void update() {
public void tick() {
if(mana > 0 && recipe == null) {
for(RecipeBrew recipe : BotaniaAPI.brewRecipes)
if(recipe.matches(itemHandler)) {
this.recipe = recipe;
world.setBlockState(pos, ModBlocks.brewery.getDefaultState().withProperty(BotaniaStateProps.POWERED, true), 1 | 2);
world.setBlockState(pos, ModBlocks.brewery.getDefaultState().with(BotaniaStateProps.POWERED, true), 1 | 2);
}
if(recipe == null)
@@ -102,7 +102,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
if(!world.isRemote && recipe == null) {
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1));
for(EntityItem item : items)
if(!item.isDead && !item.getItem().isEmpty()) {
if(item.isAlive() && !item.getItem().isEmpty()) {
ItemStack stack = item.getItem();
addItem(null, stack, null);
}
@@ -187,14 +187,14 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
super.writePacketNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_MANA, mana);
par1nbtTagCompound.setInt(TAG_MANA, mana);
}
@Override
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
super.readPacketNBT(par1nbtTagCompound);
mana = par1nbtTagCompound.getInteger(TAG_MANA);
mana = par1nbtTagCompound.getInt(TAG_MANA);
}
@Override
@@ -31,7 +31,7 @@ public class TileCacophonium extends TileMod {
NBTTagCompound cmp1 = new NBTTagCompound();
if(!stack.isEmpty())
cmp1 = stack.writeToNBT(cmp1);
cmp1 = stack.write(cmp1);
cmp.setTag(TAG_STACK, cmp1);
}
@@ -39,8 +39,8 @@ public class TileCacophonium extends TileMod {
public void readPacketNBT(NBTTagCompound cmp) {
super.readPacketNBT(cmp);
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_STACK);
stack = new ItemStack(cmp1);
NBTTagCompound cmp1 = cmp.getCompound(TAG_STACK);
stack = ItemStack.read(cmp1);
}
}
@@ -14,29 +14,28 @@ 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;
public class TileCamo extends TileMod {
private static final String TAG_CAMO = "camo";
private static final String TAG_CAMO_META = "camoMeta";
public IBlockState camoState;
@Override
public void writePacketNBT(NBTTagCompound cmp) {
if(camoState != null) {
cmp.setString(TAG_CAMO, Block.REGISTRY.getNameForObject(camoState.getBlock()).toString());
cmp.setInteger(TAG_CAMO_META, camoState.getBlock().getMetaFromState(camoState));
cmp.setTag(TAG_CAMO, NBTUtil.writeBlockState(camoState));
}
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
Block b = Block.getBlockFromName(cmp.getString(TAG_CAMO));
if (b != null) {
camoState = b.getStateFromMeta(cmp.getInteger(TAG_CAMO_META));
camoState = NBTUtil.readBlockState(cmp.getCompound(TAG_CAMO));
if(camoState.isAir()) {
camoState = null;
}
}
@@ -37,7 +37,7 @@ public class TileCell extends TileMod {
validCoords = getPos();
ticked = true;
} else if(!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower))
world.setBlockToAir(pos);
world.removeBlock(pos);
}
public boolean isSameFlower(TileEntity flower) {
@@ -54,32 +54,32 @@ public class TileCell extends TileMod {
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_GENERATION, generation);
cmp.setInt(TAG_GENERATION, generation);
cmp.setBoolean(TAG_TICKED, ticked);
if(ticked) {
cmp.setInteger(TAG_FLOWER_X, flowerCoords.getX());
cmp.setInteger(TAG_FLOWER_Y, flowerCoords.getY());
cmp.setInteger(TAG_FLOWER_Z, flowerCoords.getZ());
cmp.setInteger(TAG_VALID_X, validCoords.getX());
cmp.setInteger(TAG_VALID_Y, validCoords.getY());
cmp.setInteger(TAG_VALID_Z, validCoords.getZ());
cmp.setInt(TAG_FLOWER_X, flowerCoords.getX());
cmp.setInt(TAG_FLOWER_Y, flowerCoords.getY());
cmp.setInt(TAG_FLOWER_Z, flowerCoords.getZ());
cmp.setInt(TAG_VALID_X, validCoords.getX());
cmp.setInt(TAG_VALID_Y, validCoords.getY());
cmp.setInt(TAG_VALID_Z, validCoords.getZ());
}
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
generation = cmp.getInteger(TAG_GENERATION);
generation = cmp.getInt(TAG_GENERATION);
ticked = cmp.getBoolean(TAG_TICKED);
if(ticked) {
flowerCoords = new BlockPos(
cmp.getInteger(TAG_FLOWER_X),
cmp.getInteger(TAG_FLOWER_Y),
cmp.getInteger(TAG_FLOWER_Z)
cmp.getInt(TAG_FLOWER_X),
cmp.getInt(TAG_FLOWER_Y),
cmp.getInt(TAG_FLOWER_Z)
);
validCoords = new BlockPos(
cmp.getInteger(TAG_VALID_X),
cmp.getInteger(TAG_VALID_Y),
cmp.getInteger(TAG_VALID_Z)
cmp.getInt(TAG_VALID_X),
cmp.getInt(TAG_VALID_Y),
cmp.getInt(TAG_VALID_Z)
);
}
}
@@ -44,7 +44,7 @@ public class TileCocoon extends TileMod implements ITickable{
public int chorusFruitGiven;
@Override
public void update() {
public void tick() {
timePassed++;
if(timePassed >= TOTAL_TIME)
hatch();
@@ -114,7 +114,7 @@ public class TileCocoon extends TileMod implements ITickable{
entity.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
if(entity instanceof EntityAgeable)
((EntityAgeable) entity).setGrowingAge(-24000);
entity.onInitialSpawn(world.getDifficultyForLocation(getPos()), null);
entity.onInitialSpawn(world.getDifficultyForLocation(getPos()), null, null);
world.spawnEntity(entity);
entity.spawnExplosionParticle();
}
@@ -123,16 +123,16 @@ public class TileCocoon extends TileMod implements ITickable{
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_TIME_PASSED, timePassed);
cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven);
cmp.setInteger(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven);
cmp.setInt(TAG_TIME_PASSED, timePassed);
cmp.setInt(TAG_EMERALDS_GIVEN, emeraldsGiven);
cmp.setInt(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven);
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
timePassed = cmp.getInteger(TAG_TIME_PASSED);
emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN);
chorusFruitGiven = cmp.getInteger(TAG_CHORUS_FRUIT_GIVEN);
timePassed = cmp.getInt(TAG_TIME_PASSED);
emeraldsGiven = cmp.getInt(TAG_EMERALDS_GIVEN);
chorusFruitGiven = cmp.getInt(TAG_CHORUS_FRUIT_GIVEN);
}
}
@@ -61,7 +61,7 @@ public class TileCraftCrate extends TileOpenCrate {
}
@Override
public void update() {
public void tick() {
if (world.isRemote)
return;
@@ -133,13 +133,13 @@ public class TileCraftCrate extends TileOpenCrate {
@Override
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
super.writePacketNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_PATTERN, pattern.ordinal());
par1nbtTagCompound.setInt(TAG_PATTERN, pattern.ordinal());
}
@Override
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
super.readPacketNBT(par1nbtTagCompound);
pattern = CratePattern.values()[par1nbtTagCompound.getInteger(TAG_PATTERN)];
pattern = CratePattern.values()[par1nbtTagCompound.getInt(TAG_PATTERN)];
}
@Override
@@ -116,7 +116,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
}
public void onWanded(EntityPlayer player, ItemStack wand) {
if(stage != State.IDLE || itemToEnchant.isEmpty() || !itemToEnchant.isItemEnchantable())
if(stage != State.IDLE || itemToEnchant.isEmpty() || !itemToEnchant.isEnchantable())
return;
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX() - 2, pos.getY(), pos.getZ() - 2, pos.getX() + 3, pos.getY() + 1, pos.getZ() + 3));
@@ -127,8 +127,8 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
ItemStack item = entity.getItem();
if(item.getItem() == Items.ENCHANTED_BOOK) {
NBTTagList enchants = ItemEnchantedBook.getEnchantments(item);
if(enchants.tagCount() > 0) {
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
if(enchants.size() > 0) {
NBTTagCompound enchant = enchants.getCompound(0); // todo 1.13 update
short id = enchant.getShort("id");
if(isEnchantmentValid(Enchantment.getEnchantmentByID(id))) {
advanceStage();
@@ -141,9 +141,9 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
}
@Override
public void update() {
public void tick() {
IBlockState state = world.getBlockState(getPos());
EnumFacing.Axis axis = state.getValue(BotaniaStateProps.ENCHANTER_DIRECTION);
EnumFacing.Axis axis = state.get(BotaniaStateProps.ENCHANTER_DIRECTION);
for(BlockPos pylon : PYLON_LOCATIONS.get(axis)) {
TileEntity tile = world.getTileEntity(pos.add(pylon));
@@ -179,8 +179,8 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
ItemStack item = entity.getItem();
if(item.getItem() == Items.ENCHANTED_BOOK) {
NBTTagList enchants = ItemEnchantedBook.getEnchantments(item);
if(enchants.tagCount() > 0) {
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
if(enchants.size() > 0) {
NBTTagCompound enchant = enchants.getCompound(0);
short enchantId = enchant.getShort("id");
short enchantLvl = enchant.getShort("lvl");
Enchantment ench = Enchantment.getEnchantmentByID(enchantId);
@@ -338,15 +338,15 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
cmp.setInteger(TAG_MANA_REQUIRED, manaRequired);
cmp.setInteger(TAG_STAGE, stage.ordinal());
cmp.setInteger(TAG_STAGE_TICKS, stageTicks);
cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks);
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);
NBTTagCompound itemCmp = new NBTTagCompound();
if(!itemToEnchant.isEmpty())
itemCmp = itemToEnchant.writeToNBT(itemCmp);
itemCmp = itemToEnchant.write(itemCmp);
cmp.setTag(TAG_ITEM, itemCmp);
String enchStr = enchants.stream()
@@ -357,14 +357,14 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
@Override
public void readPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
manaRequired = cmp.getInteger(TAG_MANA_REQUIRED);
stage = State.values()[cmp.getInteger(TAG_STAGE)];
stageTicks = cmp.getInteger(TAG_STAGE_TICKS);
stage3EndTicks = cmp.getInteger(TAG_STAGE_3_END_TICKS);
mana = cmp.getInt(TAG_MANA);
manaRequired = cmp.getInt(TAG_MANA_REQUIRED);
stage = State.values()[cmp.getInt(TAG_STAGE)];
stageTicks = cmp.getInt(TAG_STAGE_TICKS);
stage3EndTicks = cmp.getInt(TAG_STAGE_3_END_TICKS);
NBTTagCompound itemCmp = cmp.getCompoundTag(TAG_ITEM);
itemToEnchant = new ItemStack(itemCmp);
NBTTagCompound itemCmp = cmp.getCompound(TAG_ITEM);
itemToEnchant = ItemStack.read(itemCmp);
enchants.clear();
String enchStr = cmp.getString(TAG_ENCHANTS);
@@ -28,11 +28,11 @@ import java.util.List;
public class TileEnderEye extends TileMod implements ITickable {
@Override
public void update() {
public void tick() {
if (world.isRemote)
return;
boolean wasLooking = world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
boolean wasLooking = world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
int range = 80;
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range, range, range)));
@@ -50,7 +50,7 @@ public class TileEnderEye extends TileMod implements ITickable {
}
if(looking != wasLooking && !world.isRemote)
world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, looking), 1 | 2);
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, looking), 1 | 2);
if(looking) {
double x = getPos().getX() - 0.1 + Math.random() * 1.2;
@@ -35,21 +35,21 @@ public class TileFakeAir extends TileMod {
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) {
NBTTagCompound ret = super.writeToNBT(par1nbtTagCompound);
ret.setInteger(TAG_FLOWER_X, flowerPos.getX());
ret.setInteger(TAG_FLOWER_Y, flowerPos.getY());
ret.setInteger(TAG_FLOWER_Z, flowerPos.getZ());
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());
return ret;
}
@Override
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
public void read(NBTTagCompound par1nbtTagCompound) {
super.read(par1nbtTagCompound);
flowerPos = new BlockPos(
par1nbtTagCompound.getInteger(TAG_FLOWER_X),
par1nbtTagCompound.getInteger(TAG_FLOWER_Y),
par1nbtTagCompound.getInteger(TAG_FLOWER_Z)
par1nbtTagCompound.getInt(TAG_FLOWER_X),
par1nbtTagCompound.getInt(TAG_FLOWER_Y),
par1nbtTagCompound.getInt(TAG_FLOWER_Z)
);
}
@@ -19,7 +19,7 @@ public class TileForestEye extends TileMod implements ITickable {
public int entities = 0;
@Override
public void update() {
public void tick() {
if (world.isRemote)
return;
int range = 6;
@@ -56,7 +56,7 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
}
@Override
public void update() {
public void tick() {
int totalTime = getTotalTime();
boolean dust = isDust();
@@ -69,11 +69,11 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
flip = !flip;
flipTicks = 4;
if(!world.isRemote) {
world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, true), 1);
world.scheduleUpdate(pos, getBlockType(), getBlockType().tickRate(world));
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, true), 1);
world.getPendingBlockTicks().scheduleTick(pos, getBlockState().getBlock(), getBlockState().getBlock().tickRate(world));
}
for(EnumFacing facing : EnumFacing.VALUES) {
for(EnumFacing facing : EnumFacing.BY_INDEX) {
BlockPos pos = getPos().offset(facing);
IBlockState state = world.getBlockState(pos);
if(state.getBlock() instanceof IHourglassTrigger)
@@ -162,10 +162,10 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
@Override
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
super.writePacketNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_TIME, time);
par1nbtTagCompound.setInt(TAG_TIME, time);
par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction);
par1nbtTagCompound.setBoolean(TAG_FLIP, flip);
par1nbtTagCompound.setInteger(TAG_FLIP_TICKS, flipTicks);
par1nbtTagCompound.setInt(TAG_FLIP_TICKS, flipTicks);
par1nbtTagCompound.setBoolean(TAG_MOVE, move);
par1nbtTagCompound.setBoolean(TAG_LOCK, lock);
}
@@ -173,10 +173,10 @@ public class TileHourglass extends TileSimpleInventory implements ITickable {
@Override
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
super.readPacketNBT(par1nbtTagCompound);
time = par1nbtTagCompound.getInteger(TAG_TIME);
time = par1nbtTagCompound.getInt(TAG_TIME);
timeFraction = par1nbtTagCompound.getFloat(TAG_TIME_FRACTION);
flip = par1nbtTagCompound.getBoolean(TAG_FLIP);
flipTicks = par1nbtTagCompound.getInteger(TAG_FLIP_TICKS);
flipTicks = par1nbtTagCompound.getInt(TAG_FLIP_TICKS);
move = par1nbtTagCompound.getBoolean(TAG_MOVE);
lock = par1nbtTagCompound.getBoolean(TAG_LOCK);
}
@@ -78,7 +78,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
}
@Override
public void update() {
public void tick() {
ticksElapsed++;
BlockPos nextDest = getNextDestination();
@@ -222,17 +222,17 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
@Override
public void readPacketNBT(NBTTagCompound cmp) {
bindPos = new BlockPos(
cmp.getInteger(TAG_BIND_X),
cmp.getInteger(TAG_BIND_Y),
cmp.getInteger(TAG_BIND_Z)
cmp.getInt(TAG_BIND_X),
cmp.getInt(TAG_BIND_Y),
cmp.getInt(TAG_BIND_Z)
);
}
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_BIND_X, bindPos.getX());
cmp.setInteger(TAG_BIND_Y, bindPos.getY());
cmp.setInteger(TAG_BIND_Z, bindPos.getZ());
cmp.setInt(TAG_BIND_X, bindPos.getX());
cmp.setInt(TAG_BIND_Y, bindPos.getY());
cmp.setInt(TAG_BIND_Z, bindPos.getZ());
}
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
@@ -262,11 +262,11 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
if(getPassengers().isEmpty() && !world.isRemote) {
setDead();
remove();
return;
}
@@ -294,12 +294,12 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
}
for(Entity e : getPassengers()) {
e.dismountRidingEntity();
e.stopRiding();
if(e instanceof EntityPlayerMP)
((EntityPlayerMP) e).connection.setPlayerLocation(posX, posY, posZ, e.rotationYaw, e.rotationPitch);
else e.setPosition(posX, posY, posZ);
}
setDead();
remove();
} else {
Vector3 thisVec = Vector3.fromEntity(this);
Vector3 motVec = thisVec.negate().add(exitPos.getX() + 0.5, exitPos.getY() + 0.5, exitPos.getZ() + 0.5).normalize().multiply(0.5);
@@ -334,16 +334,16 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
setExit(new BlockPos(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z)));
protected void readAdditional(@Nonnull NBTTagCompound cmp) {
setExit(new BlockPos(cmp.getInt(TAG_EXIT_X), cmp.getInt(TAG_EXIT_Y), cmp.getInt(TAG_EXIT_Z)));
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
BlockPos exit = getExitPos();
cmp.setInteger(TAG_EXIT_X, exit.getX());
cmp.setInteger(TAG_EXIT_Y, exit.getY());
cmp.setInteger(TAG_EXIT_Z, exit.getZ());
cmp.setInt(TAG_EXIT_X, exit.getX());
cmp.setInt(TAG_EXIT_Y, exit.getY());
cmp.setInt(TAG_EXIT_Z, exit.getZ());
}
public BlockPos getExitPos() {
@@ -30,7 +30,7 @@ public class TileManaFlame extends TileMod implements ITickable {
}
@Override
public void update() {
public void tick() {
float c = 0.3F;
if(world.isRemote && Math.random() < c) {
@@ -71,12 +71,12 @@ public class TileManaFlame extends TileMod implements ITickable {
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_COLOR, color);
cmp.setInt(TAG_COLOR, color);
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
color = cmp.getInteger(TAG_COLOR);
color = cmp.getInt(TAG_COLOR);
}
}
@@ -29,8 +29,8 @@ public class TileMod extends TileEntity {
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) {
NBTTagCompound ret = super.writeToNBT(par1nbtTagCompound);
public NBTTagCompound write(NBTTagCompound par1nbtTagCompound) {
NBTTagCompound ret = super.write(par1nbtTagCompound);
writePacketNBT(ret);
return ret;
}
@@ -38,12 +38,12 @@ public class TileMod extends TileEntity {
@Nonnull
@Override
public final NBTTagCompound getUpdateTag() {
return writeToNBT(new NBTTagCompound());
return write(new NBTTagCompound());
}
@Override
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
public void read(NBTTagCompound par1nbtTagCompound) {
super.read(par1nbtTagCompound);
readPacketNBT(par1nbtTagCompound);
}
@@ -41,12 +41,12 @@ public class TileOpenCrate extends TileSimpleInventory implements ITickable {
}
@Override
public void update() {
public void tick() {
if (world.isRemote)
return;
boolean redstone = false;
for(EnumFacing dir : EnumFacing.VALUES) {
for(EnumFacing dir : EnumFacing.BY_INDEX) {
int redstoneSide = world.getRedstonePower(pos.offset(dir), dir);
if(redstoneSide > 0) {
redstone = true;
@@ -34,7 +34,7 @@ public class TilePlatform extends TileCamo {
}
void swapSurroudings(TilePlatform tile, boolean empty) {
for(EnumFacing dir : EnumFacing.VALUES) {
for(EnumFacing dir : EnumFacing.BY_INDEX) {
BlockPos pos = tile.getPos().offset(dir);
TileEntity tileAt = world.getTileEntity(pos);
if(tileAt != null && tileAt instanceof TilePlatform) {
@@ -32,13 +32,13 @@ public class TilePylon extends TileEntity implements ITickable {
int ticks = 0;
@Override
public void update() {
public void tick() {
++ticks;
if(!(getBlockType() instanceof BlockPylon))
if(!(getBlockState().getBlock() instanceof BlockPylon))
return;
BlockPylon.Variant variant = ((BlockPylon) getBlockType()).variant;
BlockPylon.Variant variant = ((BlockPylon) getBlockState().getBlock()).variant;
if(activated && world.isRemote) {
if(world.getBlockState(centerPos).getBlock() != getBlockForMeta()
@@ -73,7 +73,7 @@ public class TilePylon extends TileEntity implements ITickable {
Block block = world.getBlockState(pos.down()).getBlock();
if(block == ModBlocks.flower || block == ModBlocks.shinyFlower) {
int hex = world.getBlockState(pos.down()).getValue(BotaniaStateProps.COLOR).colorValue;
int hex = world.getBlockState(pos.down()).get(BotaniaStateProps.COLOR).colorValue;
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -93,12 +93,12 @@ public class TilePylon extends TileEntity implements ITickable {
}
private Block getBlockForMeta() {
return ((BlockPylon) getBlockType()).variant == BlockPylon.Variant.MANA ? ModBlocks.enchanter : ModBlocks.alfPortal;
return ((BlockPylon) getBlockState().getBlock()).variant == BlockPylon.Variant.MANA ? ModBlocks.enchanter : ModBlocks.alfPortal;
}
private boolean portalOff() {
return world.getBlockState(centerPos).getBlock() != ModBlocks.alfPortal
|| world.getBlockState(centerPos).getValue(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF;
|| world.getBlockState(centerPos).get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF;
}
}
@@ -68,7 +68,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
if(stack.getItem() == Item.getItemFromBlock(ModBlocks.livingrock) && stack.getItemDamage() == 0) {
if(!world.isRemote) {
ItemStack toSpawn = player != null && player.capabilities.isCreativeMode ? stack.copy().splitStack(1) : stack.splitStack(1);
ItemStack toSpawn = player != null && player.abilities.isCreativeMode ? stack.copy().splitStack(1) : stack.splitStack(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;
@@ -90,7 +90,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
stackToAdd.setCount(1);
itemHandler.setStackInSlot(i, stackToAdd);
if(player == null || !player.capabilities.isCreativeMode) {
if(player == null || !player.abilities.isCreativeMode) {
stack.shrink(1);
}
@@ -125,7 +125,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
}
@Override
public void update() {
public void tick() {
// Update every tick.
recieveMana(0);
@@ -134,7 +134,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
if(manaToGet == 0) {
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
for(EntityItem item : items)
if(!item.isDead && !item.getItem().isEmpty() && item.getItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) {
if(item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) {
ItemStack stack = item.getItem();
addItem(null, stack, null);
}
@@ -240,7 +240,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.isDead && !item.getItem().isEmpty() && item.getItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) {
if(item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) {
livingrock = item;
break;
}
@@ -285,16 +285,16 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
public void writePacketNBT(NBTTagCompound par1nbtTagCompound) {
super.writePacketNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_MANA, mana);
par1nbtTagCompound.setInteger(TAG_MANA_TO_GET, manaToGet);
par1nbtTagCompound.setInt(TAG_MANA, mana);
par1nbtTagCompound.setInt(TAG_MANA_TO_GET, manaToGet);
}
@Override
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
super.readPacketNBT(par1nbtTagCompound);
mana = par1nbtTagCompound.getInteger(TAG_MANA);
manaToGet = par1nbtTagCompound.getInteger(TAG_MANA_TO_GET);
mana = par1nbtTagCompound.getInt(TAG_MANA);
manaToGet = par1nbtTagCompound.getInt(TAG_MANA_TO_GET);
}
@Override
@@ -14,7 +14,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
@@ -23,6 +25,7 @@ import javax.annotation.Nonnull;
public abstract class TileSimpleInventory extends TileMod {
protected SimpleItemStackHandler itemHandler = createItemHandler();
private final LazyOptional<IItemHandler> automationItemHandler = LazyOptional.of(() -> itemHandler);
@Override
public void readPacketNBT(NBTTagCompound par1NBTTagCompound) {
@@ -45,16 +48,10 @@ public abstract class TileSimpleInventory extends TileMod {
return itemHandler;
}
@Nonnull
@Override
public boolean hasCapability(@Nonnull Capability<?> cap, EnumFacing side) {
return cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(cap, side);
}
@Override
public <T> T getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemHandler);
return super.getCapability(cap, side);
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, automationItemHandler);
}
/* Extension of ItemStackHandler that uses our own slot array, allows for control of writing,
@@ -33,7 +33,7 @@ public class TileSparkChanger extends TileSimpleInventory {
ItemStack changeStack = itemHandler.getStackInSlot(0);
List<ISparkAttachable> attachables = new ArrayList<>();
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) {
TileEntity tile = world.getTileEntity(pos.offset(dir));
if(tile != null && tile instanceof ISparkAttachable) {
ISparkAttachable attach = (ISparkAttachable) tile;
@@ -34,7 +34,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
int mana = 0;
@Override
public void update() {
public void tick() {
TileEntity tileBelow = world.getTileEntity(pos.down());
if(mana >= 5 && tileBelow instanceof TileEntityMobSpawner) {
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow;
@@ -47,7 +47,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
if(!world.isRemote)
mana -= 6;
if(logic.getSpawnerWorld().isRemote) {
if(logic.getWorld().isRemote) {
if(logic.spawnDelay > 0) {
--logic.spawnDelay;
}
@@ -120,12 +120,12 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
cmp.setInt(TAG_MANA, mana);
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
mana = cmp.getInt(TAG_MANA);
}
@Override
@@ -76,9 +76,9 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
}
@Override
public void update() {
public void tick() {
if(subTile != null) {
world.profiler.func_194340_a(() -> subTileName.toString());
world.profiler.startSection(() -> subTileName.toString());
TileEntity tileBelow = world.getTileEntity(pos.down());
if(tileBelow instanceof TileRedStringRelay) {
BlockPos coords = ((TileRedStringRelay) tileBelow).getBinding();
@@ -129,7 +129,7 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
super.readPacketNBT(cmp);
subTileName = new ResourceLocation(cmp.getString(TAG_SUBTILE_NAME));
NBTTagCompound subCmp = cmp.getCompoundTag(TAG_SUBTILE_CMP);
NBTTagCompound subCmp = cmp.getCompound(TAG_SUBTILE_CMP);
if(subTile == null || !BotaniaAPI.getSubTileStringMapping(subTile.getClass()).equals(subTileName))
provideSubTile(subTileName);
@@ -230,10 +230,8 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
if(below == Blocks.MYCELIUM)
return SLOWDOWN_FACTOR_MYCEL;
if(below == Blocks.DIRT) {
BlockDirt.DirtType type = world.getBlockState(getPos().down()).getValue(BlockDirt.VARIANT);
if(type == BlockDirt.DirtType.PODZOL)
return SLOWDOWN_FACTOR_PODZOL;
if(below == Blocks.PODZOL) {
return SLOWDOWN_FACTOR_PODZOL;
}
return 0;
@@ -18,7 +18,7 @@ public class TileSpiritShrine extends TileMod implements ITickable {
int ticks;
@Override
public void update() {
public void tick() {
if(world.isRemote) {
if(ticks >= 40) {
float[][] colors = new float[][] {
@@ -17,12 +17,12 @@ import vazkii.botania.common.Botania;
public class TileStarfield extends TileMod implements ITickable {
@Override
public void update() {
boolean state = world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
public void tick() {
boolean state = world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
if(!world.isRemote) {
boolean newState = !world.isDaytime();
if(newState != state) {
world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, newState), 1 | 2);
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, newState), 1 | 2);
state = newState;
}
}
@@ -71,7 +71,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
}
@Override
public void update() {
public void tick() {
if(world.isRemote)
return;
@@ -102,7 +102,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
EntityItem item = items.get(0);
for(EntityItem otherItem : items)
if(otherItem != item)
otherItem.setDead();
otherItem.remove();
else item.setItem(new ItemStack(ModItems.terrasteel));
world.playSound(null, item.posX, item.posY, item.posZ, ModSounds.terrasteelCraft, SoundCategory.BLOCKS, 1, 1);
mana = 0;
@@ -163,12 +163,12 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
cmp.setInt(TAG_MANA, mana);
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
mana = cmp.getInt(TAG_MANA);
}
@Override
@@ -18,7 +18,7 @@ public class TileTeruTeruBozu extends TileMod implements ITickable {
public boolean wasRaining = false;
@Override
public void update() {
public void tick() {
if (world.isRemote)
return;
@@ -16,7 +16,7 @@ import vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet;
public class TileTinyPlanet extends TileMod implements ITickable {
@Override
public void update() {
public void tick() {
ItemTinyPlanet.applyEffect(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
}
@@ -44,7 +44,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickable {
player.setHeldItem(hand, stackAt);
getItemHandler().setStackInSlot(index, ItemStack.EMPTY);
} else if(!stack.isEmpty()) {
ItemStack copy = stack.splitStack(1);
ItemStack copy = stack.split(1);
if(stack.isEmpty())
player.setHeldItem(hand, stackAt);
@@ -82,7 +82,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickable {
}
@Override
public void update() {
public void tick() {
if(world.rand.nextInt(100) == 0)
jump();
@@ -17,12 +17,13 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.model.ModelLoaderRegistry;
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.fml.relauncher.Side;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.loading.FMLEnvironment;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaRequestor;
import vazkii.botania.api.corporea.ICorporeaSpark;
@@ -44,17 +45,20 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
int compValue = 0;
private final IAnimationStateMachine asm;
private final LazyOptional<IAnimationStateMachine> asmCap;
public TileCorporeaCrystalCube() {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
if (FMLEnvironment.dist == Dist.CLIENT) {
asm = ModelLoaderRegistry.loadASM(new ResourceLocation("botania", "asms/block/corporeacrystalcube.json"), ImmutableMap.of());
asmCap = LazyOptional.of(() -> asm);
} else {
asm = null;
asmCap = LazyOptional.empty();
}
}
@Override
public void update() {
public void tick() {
++ticks;
if(ticks % 20 == 0)
updateCount();
@@ -122,17 +126,17 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
super.writePacketNBT(par1nbtTagCompound);
NBTTagCompound cmp = new NBTTagCompound();
if(!requestTarget.isEmpty())
cmp = requestTarget.writeToNBT(cmp);
cmp = requestTarget.write(cmp);
par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp);
par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount);
par1nbtTagCompound.setInt(TAG_ITEM_COUNT, itemCount);
}
@Override
public void readPacketNBT(NBTTagCompound par1nbtTagCompound) {
super.readPacketNBT(par1nbtTagCompound);
NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET);
requestTarget = new ItemStack(cmp);
itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT);
NBTTagCompound cmp = par1nbtTagCompound.getCompound(TAG_REQUEST_TARGET);
requestTarget = ItemStack.read(cmp);
itemCount = par1nbtTagCompound.getInt(TAG_ITEM_COUNT);
}
public int getComparatorValue() {
@@ -162,14 +166,9 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
}
@Override
public boolean hasCapability(@Nonnull Capability<?> cap, EnumFacing side) {
return cap == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(cap, side);
}
@Override
public <T> T getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
if(cap == CapabilityAnimation.ANIMATION_CAPABILITY) {
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
return asmCap.cast();
} else return super.getCapability(cap, side);
}
@@ -48,7 +48,7 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq
1, 2, 4, 8, 16, 32, 48, 64
};
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) {
List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
for(EntityItemFrame frame : frames) {
EnumFacing orientation = frame.facingDirection;
@@ -20,12 +20,12 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.commons.lang3.text.WordUtils;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.CorporeaIndexRequestEvent;
@@ -167,7 +167,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
public boolean hasCloseby;
@Override
public void update() {
public void tick() {
double x = pos.getX() + 0.5;
double y = pos.getY() + 0.5;
double z = pos.getZ() + 0.5;
@@ -189,19 +189,19 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
} else if(closeby > 0F)
closeby -= step;
if(!isInvalid())
if(!isRemoved())
addIndex(this);
}
@Override
public void invalidate() {
super.invalidate();
public void remove() {
super.remove();
removeIndex(this);
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
public void onChunkUnloaded() {
super.onChunkUnloaded();
removeIndex(this);
}
@@ -220,7 +220,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
}
public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) {
return player.world.provider.getDimension() == index.world.provider.getDimension() && 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().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;
}
public static void addPattern(String pattern, IRegexStacker stacker) {
@@ -305,9 +305,9 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public boolean shouldAutoComplete() {
return !getNearbyIndexes(Minecraft.getMinecraft().player).isEmpty();
return !getNearbyIndexes(Minecraft.getInstance().player).isEmpty();
}
}
@@ -38,14 +38,14 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor
for(ItemStack stack_ : stacks)
missing -= stack_.getCount();
if(missing > 0 && !world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED)) {
world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, true), 1 | 2);
world.scheduleUpdate(getPos(), getBlockType(), 2);
if(missing > 0 && !world.getBlockState(getPos()).get(BotaniaStateProps.POWERED)) {
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, true), 1 | 2);
world.getPendingBlockTicks().scheduleTick(getPos(), getBlockState().getBlock(), 2);
TileEntity requestor = source.getSparkInventory().world.getTileEntity(source.getSparkInventory().pos);
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
for(EnumFacing dir : EnumFacing.BY_INDEX) {
TileEntity tile = world.getTileEntity(pos.offset(dir));
if(tile != null && tile instanceof TileCorporeaRetainer)
if(tile instanceof TileCorporeaRetainer)
((TileCorporeaRetainer) tile).setPendingRequest(requestor.getPos(), request, count);
}
@@ -71,7 +71,7 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor
public List<ItemStack> getFilter() {
List<ItemStack> filter = new ArrayList<>();
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
for(EnumFacing dir : EnumFacing.BY_INDEX) {
List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
for(EntityItemFrame frame : frames) {
EnumFacing orientation = frame.facingDirection;
@@ -82,26 +82,26 @@ public class TileCorporeaRetainer extends TileMod {
super.writePacketNBT(cmp);
cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest);
cmp.setInteger(TAG_REQUEST_X, requestPos.getX());
cmp.setInteger(TAG_REQUEST_Y, requestPos.getY());
cmp.setInteger(TAG_REQUEST_Z, requestPos.getZ());
cmp.setInt(TAG_REQUEST_X, requestPos.getX());
cmp.setInt(TAG_REQUEST_Y, requestPos.getY());
cmp.setInt(TAG_REQUEST_Z, requestPos.getZ());
int reqType = REQUEST_NULL;
if(request != null)
reqType = request instanceof String ? REQUEST_STRING : REQUEST_ITEMSTACK;
cmp.setInteger(TAG_REQUEST_TYPE, reqType);
cmp.setInt(TAG_REQUEST_TYPE, reqType);
switch (reqType) {
case REQUEST_STRING:
cmp.setString(TAG_REQUEST_CONTENTS, (String) request);
break;
case REQUEST_ITEMSTACK:
NBTTagCompound cmp1 = ((ItemStack) request).writeToNBT(new NBTTagCompound());
NBTTagCompound cmp1 = ((ItemStack) request).write(new NBTTagCompound());
cmp.setTag(TAG_REQUEST_STACK, cmp1);
break;
default: break;
}
cmp.setInteger(TAG_REQUEST_COUNT, requestCount);
cmp.setInt(TAG_REQUEST_COUNT, requestCount);
}
@Override
@@ -109,23 +109,23 @@ public class TileCorporeaRetainer extends TileMod {
super.readPacketNBT(cmp);
pendingRequest = cmp.getBoolean(TAG_PENDING_REQUEST);
int x = cmp.getInteger(TAG_REQUEST_X);
int y = cmp.getInteger(TAG_REQUEST_Y);
int z = cmp.getInteger(TAG_REQUEST_Z);
int x = cmp.getInt(TAG_REQUEST_X);
int y = cmp.getInt(TAG_REQUEST_Y);
int z = cmp.getInt(TAG_REQUEST_Z);
requestPos = new BlockPos(x, y, z);
int reqType = cmp.getInteger(TAG_REQUEST_TYPE);
int reqType = cmp.getInt(TAG_REQUEST_TYPE);
switch (reqType) {
case REQUEST_STRING:
request = cmp.getString(TAG_REQUEST_CONTENTS);
break;
case REQUEST_ITEMSTACK:
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_REQUEST_STACK);
request = new ItemStack(cmp1);
NBTTagCompound cmp1 = cmp.getCompound(TAG_REQUEST_STACK);
request = ItemStack.read(cmp1);
break;
default: break;
}
requestCount = cmp.getInteger(TAG_REQUEST_COUNT);
requestCount = cmp.getInt(TAG_REQUEST_COUNT);
}
}
@@ -29,7 +29,7 @@ public abstract class TileRedString extends TileMod implements ITileBound, ITick
private BlockPos binding;
@Override
public void update() {
public void tick() {
EnumFacing dir = getOrientation();
BlockPos pos_ = getPos();
int range = getRange();
@@ -79,8 +79,8 @@ public abstract class TileRedString extends TileMod implements ITileBound, ITick
public EnumFacing getOrientation() {
IBlockState state = world.getBlockState(getPos());
if(state.getPropertyKeys().contains(BotaniaStateProps.FACING))
return state.getValue(BotaniaStateProps.FACING);
if(state.getProperties().contains(BotaniaStateProps.FACING))
return state.get(BotaniaStateProps.FACING);
return EnumFacing.WEST; // fallback
}
@@ -18,8 +18,8 @@ public class TileRedStringComparator extends TileRedString {
private int comparatorValue = 0;
@Override
public void update() {
super.update();
public void tick() {
super.tick();
BlockPos binding = getBinding();
IBlockState state = getStateAtBinding();
int origVal = comparatorValue;
@@ -14,6 +14,7 @@ import net.minecraft.tileentity.TileEntity;
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 javax.annotation.Nonnull;
@@ -25,24 +26,16 @@ public class TileRedStringContainer extends TileRedString {
public boolean acceptBlock(BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
return tile != null
&& Arrays.stream(EnumFacing.VALUES)
&& Arrays.stream(EnumFacing.BY_INDEX)
.anyMatch(e -> tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e));
}
@Nonnull
@Override
public boolean hasCapability(@Nonnull Capability<?> cap, EnumFacing side) {
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
// todo 1.13 need to invalidate when binding breaks
if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY
&& getTileAtBinding() != null
&& getTileAtBinding().hasCapability(cap, side))
return true;
return super.hasCapability(cap, side);
}
@Override
public <T> T getCapability(@Nonnull Capability<T> cap, EnumFacing side) {
if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY
&& getTileAtBinding() != null
&& getTileAtBinding().hasCapability(cap, side))
&& getTileAtBinding() != null)
return getTileAtBinding().getCapability(cap, side);
return super.getCapability(cap, side);
}
@@ -27,7 +27,7 @@ public class TileRedStringDispenser extends TileRedStringContainer {
if(bind != null) {
TileEntity tile = world.getTileEntity(bind);
if(tile instanceof TileEntityDispenser)
world.scheduleUpdate(bind, tile.getBlockType(), tile.getBlockType().tickRate(world));
world.getPendingBlockTicks().scheduleTick(bind, tile.getBlockState().getBlock(), tile.getBlockState().getBlock().tickRate(world));
}
}
@@ -29,8 +29,8 @@ public class TileRedStringInterceptor extends TileRedString {
private static final Set<TileRedStringInterceptor> interceptors = new HashSet<>();
@Override
public void update() {
super.update();
public void tick() {
super.tick();
if(!world.isRemote)
interceptors.add(this);
}
@@ -41,7 +41,7 @@ public class TileRedStringInterceptor extends TileRedString {
}
private boolean saneState() {
return !isInvalid() && world.getTileEntity(pos) == this;
return !isRemoved() && world.getTileEntity(pos) == this;
}
public static void onInteract(EntityPlayer player, World world, BlockPos pos, EnumHand hand) {
@@ -61,9 +61,9 @@ public class TileRedStringInterceptor extends TileRedString {
if(inter.world == world) {
BlockPos coords = inter.getBinding();
if(coords != null && coords.equals(pos)) {
Block block = inter.getBlockType();
world.setBlockState(inter.getPos(), world.getBlockState(inter.getPos()).withProperty(BotaniaStateProps.POWERED, true), 1 | 2);
world.scheduleUpdate(inter.getPos(), block, block.tickRate(world));
Block block = inter.getBlockState().getBlock();
world.setBlockState(inter.getPos(), world.getBlockState(inter.getPos()).with(BotaniaStateProps.POWERED, true), 1 | 2);
world.getPendingBlockTicks().scheduleTick(inter.getPos(), block, block.tickRate(world));
did = true;
}
}