Floaters all rendering properly statically

This commit is contained in:
Vincent Lee committed 2019-10-30 01:37:58 -05:00
1 parent eadfa10e82
commit bb886f49e4
136 files changed
+1051 -23

No files matched your search

@@ -15,6 +15,7 @@ package vazkii.botania.api.subtile;
* BlockFlower would be checked against, but isn't convenient for
* the special flowers with effects. For Azanor and Lycaon.
*/
// todo 1.14 remove
public interface ISpecialFlower {
}
@@ -160,6 +160,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
@Override
public void readFromPacketNBT(CompoundNBT cmp) {
super.readFromPacketNBT(cmp);
mana = cmp.getInt(TAG_MANA);
int x = cmp.getInt(TAG_POOL_X);
@@ -171,6 +172,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
@Override
public void writeToPacketNBT(CompoundNBT cmp) {
super.writeToPacketNBT(cmp);
cmp.putInt(TAG_MANA, mana);
if(cachedPoolCoordinates != null) {
@@ -252,6 +252,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
@Override
public void readFromPacketNBT(CompoundNBT cmp) {
super.readFromPacketNBT(cmp);
mana = cmp.getInt(TAG_MANA);
passiveDecayTicks = cmp.getInt(TAG_PASSIVE_DECAY_TICKS);
@@ -264,6 +265,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
@Override
public void writeToPacketNBT(CompoundNBT cmp) {
super.writeToPacketNBT(cmp);
cmp.putInt(TAG_MANA, mana);
cmp.putInt(TAG_TICKS_EXISTED, ticksExisted);
cmp.putInt(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks);
@@ -43,6 +43,7 @@ import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.ModelDataManager;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
@@ -160,8 +161,6 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
super.read(cmp);
if(cmp.contains(TAG_TICKS_EXISTED))
ticksExisted = cmp.getInt(TAG_TICKS_EXISTED);
if(cmp.contains(TAG_FLOATING_DATA))
BotaniaAPI.FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
readFromPacketNBT(cmp);
}
@@ -169,7 +168,6 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
@Override
public final CompoundNBT write(CompoundNBT cmp) {
cmp.putInt(TAG_TICKS_EXISTED, ticksExisted);
cmp.put(TAG_FLOATING_DATA, BotaniaAPI.FLOATING_FLOWER_CAP.writeNBT(floatingData, null));
writeToPacketNBT(cmp);
return cmp;
}
@@ -184,8 +182,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) {
IFloatingFlower.IslandType oldType = floatingData.getIslandType();
super.onDataPacket(net, packet);
readFromPacketNBT(packet.getNbtCompound());
if(oldType != floatingData.getIslandType() && isFloating()) {
ModelDataManager.requestModelDataRefresh(this);
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 0);
}
}
@@ -201,23 +200,25 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
* by readFromPacketNBT on the client that receives the packet.
* Note: This method is also used to write to the world NBT.
*/
public void writeToPacketNBT(CompoundNBT cmp) { }
public void writeToPacketNBT(CompoundNBT cmp) {
if (isFloating())
cmp.put(TAG_FLOATING_DATA, BotaniaAPI.FLOATING_FLOWER_CAP.writeNBT(floatingData, null));
}
/**
* Reads data from a network packet. This data is written by
* writeToPacketNBT in the server. Note: This method is also used
* to read from the world NBT.
*/
public void readFromPacketNBT(CompoundNBT cmp) { }
public void readFromPacketNBT(CompoundNBT cmp) {
if(cmp.contains(TAG_FLOATING_DATA))
BotaniaAPI.FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
}
public void sync() {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
public String getUnlocalizedName() {
return getType().getRegistryName().toString();
}
/**
* Called when a Wand of the Forest is used on this sub tile. Note that the
* player parameter can be null if this is called from a dispenser.
@@ -124,7 +124,8 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
@Override
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
return ((TileEntitySpecialFlower) world.getTileEntity(pos)).onBlockActivated(world, pos, state, player, hand, hit) || super.onBlockActivated(state, world, pos, player, hand, hit);
return super.onBlockActivated(state, world, pos, player, hand, hit)
|| ((TileEntitySpecialFlower) world.getTileEntity(pos)).onBlockActivated(world, pos, state, player, hand, hit) || super.onBlockActivated(state, world, pos, player, hand, hit);
}
@Override
@@ -42,21 +42,14 @@ public class TileFloatingFlower extends TileMod {
public static TileEntityType<TileFloatingFlower> TYPE;
private static final String TAG_FLOATING_DATA = "floating";
public static ItemStack forcedStack = ItemStack.EMPTY;
private final IFloatingFlower floatingData = new FloatingFlowerImpl() {
@Override
public ItemStack getDisplayStack() {
if(!forcedStack.isEmpty()) {
ItemStack retStack = forcedStack;
forcedStack = ItemStack.EMPTY;
return retStack;
Block b = getBlockState().getBlock();
if(b instanceof BlockFloatingFlower) {
return new ItemStack(ModBlocks.getShinyFlower(((BlockFloatingFlower) b).color));
} else {
Block b = getBlockState().getBlock();
if(b instanceof BlockFloatingFlower) {
return new ItemStack(ModBlocks.getShinyFlower(((BlockFloatingFlower) b).color));
} else {
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;
}
}
};