Move nonfabulous pools into static renderer. Yay performance improvements!

This commit is contained in:
Vincent Lee committed 2016-05-02 19:20:31 -05:00
1 parent 725ae1cef1
commit 8f4f63453a
5 files changed
+29 -15

No files matched your search

@@ -55,7 +55,7 @@ public final class ColorHandler {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.getHSBColor(time * 0.005F, 0.6F, 1F).hashCode();
} else {
return 16777215;
return state.getValue(BotaniaStateProps.COLOR).getMapColor().colorValue;
}
}
},
@@ -608,7 +608,8 @@ public final class ModelHandler {
ModelLoader.setCustomStateMapper(ModBlocks.doubleFlower1, (new StateMap.Builder()).ignore(BlockDoublePlant.VARIANT, BlockDoublePlant.FACING).build());
ModelLoader.setCustomStateMapper(ModBlocks.doubleFlower2, (new StateMap.Builder()).ignore(BlockDoublePlant.VARIANT, BlockDoublePlant.FACING).build());
// Ignore color in unstable cube, mana beacon, special flower, and petals (handled by Block.colorMultiplier)
// Ignore color in pool, unstable cube, mana beacon, special flower, and petals (handled by Block.colorMultiplier)
ModelLoader.setCustomStateMapper(ModBlocks.pool, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
ModelLoader.setCustomStateMapper(ModBlocks.unstableBlock, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
ModelLoader.setCustomStateMapper(ModBlocks.manaBeacon, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
ModelLoader.setCustomStateMapper(ModBlocks.petalBlock, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
@@ -63,22 +63,19 @@ public class RenderTilePool extends TileEntitySpecialRenderer<TilePool> {
boolean fab = pool == null ? forceVariant == PoolVariant.FABULOUS : pool.getWorld().getBlockState(pool.getPos()).getValue(BotaniaStateProps.POOL_VARIANT) == PoolVariant.FABULOUS;
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
int color;
if (fab) {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
if(pool != null)
time += new Random(pool.getPos().getX() ^ pool.getPos().getY() ^ pool.getPos().getZ()).nextInt(100000);
color = Color.getHSBColor(time * 0.005F, 0.6F, 1F).hashCode();
} else {
color = pool == null ? EnumDyeColor.WHITE.getMapColor().colorValue : pool.getColor().getMapColor().colorValue;
int color = Color.getHSBColor(time * 0.005F, 0.6F, 1F).hashCode();
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(pool == null ? ModBlocks.pool.getDefaultState().withProperty(BotaniaStateProps.POOL_VARIANT, forceVariant) : pool.getWorld().getBlockState(pool.getPos()));
int red = (color & 0xFF0000) >> 16;
int green = (color & 0xFF00) >> 8;
int blue = (color & 0xFF);
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(model, 1.0F, red / 255F, green / 255F, blue / 255F);
}
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(pool == null ? ModBlocks.pool.getDefaultState().withProperty(BotaniaStateProps.POOL_VARIANT, forceVariant) : pool.getWorld().getBlockState(pool.getPos()));
int red = (color & 0xFF0000) >> 16;
int green = (color & 0xFF00) >> 8;
int blue = (color & 0xFF);
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(model, 1.0F, red / 255F, green / 255F, blue / 255F);
GlStateManager.translate(0.5F, 1.5F, 0.5F);
GlStateManager.color(1, 1, 1, a);
GlStateManager.enableRescaleNormal();
@@ -21,6 +21,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
@@ -62,13 +63,15 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
setHardness(2.0F);
setResistance(10.0F);
setSoundType(SoundType.STONE);
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.POOL_VARIANT, PoolVariant.DEFAULT));
setDefaultState(blockState.getBaseState()
.withProperty(BotaniaStateProps.POOL_VARIANT, PoolVariant.DEFAULT)
.withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE));
BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE);
}
@Override
public BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BotaniaStateProps.POOL_VARIANT);
return new BlockStateContainer(this, BotaniaStateProps.POOL_VARIANT, BotaniaStateProps.COLOR);
}
@Override
@@ -84,6 +87,16 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
return getDefaultState().withProperty(BotaniaStateProps.POOL_VARIANT, PoolVariant.values()[meta]);
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TilePool) {
return state.withProperty(BotaniaStateProps.COLOR, ((TilePool) te).color);
} else {
return state.withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE);
}
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
return AABB;
@@ -176,7 +189,9 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
if (state.getValue(BotaniaStateProps.POOL_VARIANT) == PoolVariant.FABULOUS)
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
else return EnumBlockRenderType.MODEL;
}
@Override
@@ -440,6 +440,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
@Override
public void setColor(EnumDyeColor color) {
this.color = color;
worldObj.notifyBlockUpdate(pos, worldObj.getBlockState(pos), worldObj.getBlockState(pos), 0b1011);
}
@Override