From 988e80a3f286611b5992ee0ebe20e3b9c01624e0 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Fri, 12 Feb 2016 23:07:21 -0600 Subject: [PATCH] Initial attempt at animated corporea crystal cube --- .../client/core/proxy/ClientProxy.java | 2 +- .../corporea/BlockCorporeaCrystalCube.java | 69 +++++++----------- .../corporea/TileCorporeaCrystalCube.java | 24 +++++- .../armatures/block/crystalcube_cube.json | 19 +++++ .../botania/asms/block/crystalcube_cube.json | 11 +++ .../blockstates/corporeaCrystalCube.json | 26 ++++++- .../models/block/crystalcube_base.json | 29 ++++++++ .../models/block/crystalcube_cube.json | 20 +++++ .../models/item/corporeaCrystalCube.json | 3 - .../model/crystalCube_base_bottom.png | Bin 0 -> 354 bytes .../textures/model/crystalCube_base_sides.png | Bin 0 -> 536 bytes .../textures/model/crystalCube_base_top.png | Bin 0 -> 501 bytes .../textures/model/crystalCube_cube.png | Bin 0 -> 346 bytes .../textures/model/crystalCube_stand.png | Bin 0 -> 256 bytes 14 files changed, 155 insertions(+), 48 deletions(-) create mode 100644 src/main/resources/assets/botania/armatures/block/crystalcube_cube.json create mode 100644 src/main/resources/assets/botania/asms/block/crystalcube_cube.json create mode 100644 src/main/resources/assets/botania/models/block/crystalcube_base.json create mode 100644 src/main/resources/assets/botania/models/block/crystalcube_cube.json delete mode 100644 src/main/resources/assets/botania/models/item/corporeaCrystalCube.json create mode 100644 src/main/resources/assets/botania/textures/model/crystalCube_base_bottom.png create mode 100644 src/main/resources/assets/botania/textures/model/crystalCube_base_sides.png create mode 100644 src/main/resources/assets/botania/textures/model/crystalCube_base_top.png create mode 100644 src/main/resources/assets/botania/textures/model/crystalCube_cube.png create mode 100644 src/main/resources/assets/botania/textures/model/crystalCube_stand.png diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index 5f89fbdf5..3d8078735 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -242,7 +242,7 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism()); ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new AnimationTESR<>()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new AnimationTESR<>()); ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger()); diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java index 87c1b383d..c1e0ffcf1 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -12,6 +12,8 @@ package vazkii.botania.common.block.corporea; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.client.particle.EntityDiggingFX; import net.minecraft.entity.EntityLivingBase; @@ -21,7 +23,12 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.property.ExtendedBlockState; +import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.common.property.IUnlistedProperty; +import net.minecraftforge.common.property.Properties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.lexicon.ILexiconable; @@ -42,6 +49,27 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi setStepSound(soundTypeMetal); float f = (1F - 10F / 16F) / 2F; setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); + setDefaultState(((IExtendedBlockState) blockState.getBaseState()).withProperty(Properties.AnimationProperty, null).withProperty(Properties.StaticProperty, true)); + } + + @Override + public BlockState createBlockState() { + return new ExtendedBlockState(this, new IProperty[] { Properties.StaticProperty }, new IUnlistedProperty[] { Properties.AnimationProperty } ); + } + + @Override + public int getMetaFromState(IBlockState state) { + return 0; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return getDefaultState(); + } + + @Override + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { + return state.withProperty(Properties.StaticProperty, true); } @Override @@ -74,11 +102,6 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi return false; } - @Override - public int getRenderType() { - return 2; - } - @Override public TileCorporeaBase createNewTileEntity(World world, int meta) { return new TileCorporeaCrystalCube(); @@ -99,40 +122,4 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi return ((TileCorporeaCrystalCube) world.getTileEntity(pos)).compValue; } - @Override - public boolean addLandingEffects(net.minecraft.world.WorldServer worldObj, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles ) - { - float f = (float) MathHelper.ceiling_float_int(entity.fallDistance - 3.0F); - double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F); - if (d0 > 2.5D) { - d0 = 2.5D; - } - int i = (int)(150.0D * d0); - worldObj.spawnParticle(EnumParticleTypes.BLOCK_DUST, entity.posX, entity.posY, entity.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, Block.getStateId(ModBlocks.storage.getDefaultState().withProperty(BotaniaStateProps.STORAGE_VARIANT, StorageVariant.ELEMENTIUM))); - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.EffectRenderer effectRenderer) - { - if (world.getBlockState(pos).getBlock() == this) { - int i = 4; - EntityDiggingFX.Factory factory = new EntityDiggingFX.Factory(); - for (int j = 0; j < i; ++j) { - for (int k = 0; k < i; ++k) { - for (int l = 0; l < i; ++l) { - double d0 = (double)pos.getX() + ((double)j + 0.5D) / (double)i; - double d1 = (double)pos.getY() + ((double)k + 0.5D) / (double)i; - double d2 = (double)pos.getZ() + ((double)l + 0.5D) / (double)i; - effectRenderer.addEffect(factory.getEntityFX(-1, world, d0, d1, d2, d0 - (double)pos.getX() - 0.5D, d1 - (double)pos.getY() - 0.5D, d2 - (double)pos.getZ() - 0.5D, Block.getStateId(ModBlocks.storage.getDefaultState().withProperty(BotaniaStateProps.STORAGE_VARIANT, StorageVariant.ELEMENTIUM)))); - } - } - } - return true; - } else { - return false; - } - } - } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java index 55cfb963a..8e81721f9 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java @@ -12,16 +12,24 @@ package vazkii.botania.common.block.tile.corporea; import java.util.List; +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.util.ResourceLocation; +import net.minecraftforge.client.model.animation.Animation; +import net.minecraftforge.client.model.animation.IAnimationProvider; +import net.minecraftforge.client.model.animation.TimeValues; +import net.minecraftforge.common.model.animation.IAnimationStateMachine; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; 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; -public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor { +public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor, IAnimationProvider { private static final String TAG_REQUEST_TARGET = "requestTarget"; private static final String TAG_ITEM_COUNT = "itemCount"; @@ -33,6 +41,16 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor int ticks = 0; public int compValue = 0; + private final IAnimationStateMachine asm; + + public TileCorporeaCrystalCube() { + if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { + asm = Animation.INSTANCE.load(new ResourceLocation("botania", "asms/block/crystalcube_cube.json"), ImmutableMap.of()); + } else { + asm = null; + } + } + @Override public void updateEntity() { ++ticks; @@ -156,4 +174,8 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor } } + @Override + public IAnimationStateMachine asm() { + return asm; + } } diff --git a/src/main/resources/assets/botania/armatures/block/crystalcube_cube.json b/src/main/resources/assets/botania/armatures/block/crystalcube_cube.json new file mode 100644 index 000000000..4d895e08e --- /dev/null +++ b/src/main/resources/assets/botania/armatures/block/crystalcube_cube.json @@ -0,0 +1,19 @@ +{ + "joints": { + "all": { "0": [ 1.0 ] } + }, + "clips": { + "moving": { + "loop": false, + "joint_clips": { + "all": [{ + "variable": "offset_y", + "type": "uniform", + "interpolation": "linear", + "samples": [ 0, 0.5, 0 ] + }] + }, + "events": {} + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/asms/block/crystalcube_cube.json b/src/main/resources/assets/botania/asms/block/crystalcube_cube.json new file mode 100644 index 000000000..b979aa474 --- /dev/null +++ b/src/main/resources/assets/botania/asms/block/crystalcube_cube.json @@ -0,0 +1,11 @@ +{ + "parameters": { + "world_to_cycle": [ "/", 10 ] + }, + "clips": { + "moving": [ "apply", "botania:block/crystalcube_cube@moving", "#world_to_cycle" ] + }, + "states": [ "moving" ], + "transitions": {}, + "start_state": "moving" +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/blockstates/corporeaCrystalCube.json b/src/main/resources/assets/botania/blockstates/corporeaCrystalCube.json index dc3cd27b2..96f3e56d8 100644 --- a/src/main/resources/assets/botania/blockstates/corporeaCrystalCube.json +++ b/src/main/resources/assets/botania/blockstates/corporeaCrystalCube.json @@ -1,12 +1,34 @@ { "forge_marker": 1, "defaults": { - "model": "botania:dummy", "textures": { + "stand": "botania:model/crystalCube_stand", + "base_sides": "botania:model/crystalCube_base_sides", + "base_top": "botania:model/crystalCube_base_top", + "base_bottom": "botania:model/crystalCube_base_bottom", + "cube": "botania:model/crystalCube_cube", "particle": "botania:blocks/storage2" } }, "variants": { - "normal": [{}] + "static": { + "true": { + "model": "botania:crystalcube_base" + }, + "false": { + "model": "botania:crystalcube_cube" + } + }, + "inventory": [{ + "model": "botania:crystalcube_base", + "submodel": { + "cube": { + "model": "botania:crystalcube_cube", + "transform": { + "translation": [ 0, 0.5, 0 ] + } + } + } + }] } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/crystalcube_base.json b/src/main/resources/assets/botania/models/block/crystalcube_base.json new file mode 100644 index 000000000..e14c4f028 --- /dev/null +++ b/src/main/resources/assets/botania/models/block/crystalcube_base.json @@ -0,0 +1,29 @@ +{ + "elements": [ + { + "name": "Stand", + "from": [ 5.0, 0.0, 5.0 ], + "to": [ 11.0, 1.0, 11.0 ], + "faces": { + "west": { "texture": "#stand", "uv": [ 5.0, 7.0, 11.0, 8.0 ] }, + "north": { "texture": "#stand", "uv": [ 5.0, 9.0, 11.0, 10.0 ] }, + "east": { "texture": "#stand", "uv": [ 5.0, 11.0, 11.0, 12.0 ] }, + "south": { "texture": "#stand", "uv": [ 5.0, 13.0, 11.0, 14.0 ] }, + "down": { "texture": "#stand", "uv": [ 8.0, 0.0, 14.0, 6.0 ] } + } + }, + { + "name": "Base", + "from": [ 3.0, 1.0, 3.0 ], + "to": [ 13.0, 5.0, 13.0 ], + "faces": { + "west": { "texture": "#base_sides", "uv": [ 3.0, 0.0, 13.0, 4.0 ] }, + "north": { "texture": "#base_sides", "uv": [ 3.0, 4.0, 13.0, 8.0 ] }, + "east": { "texture": "#base_sides", "uv": [ 3.0, 8.0, 13.0, 12.0 ] }, + "south": { "texture": "#base_sides", "uv": [ 3.0, 12.0, 13.0, 16.0 ] }, + "up": { "texture": "#base_top", "uv": [ 3.0, 3.0, 13.0, 13.0 ] }, + "down": { "texture": "#base_bottom", "uv": [ 3.0, 3.0, 13.0, 13.0 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/crystalcube_cube.json b/src/main/resources/assets/botania/models/block/crystalcube_cube.json new file mode 100644 index 000000000..2dd79d29d --- /dev/null +++ b/src/main/resources/assets/botania/models/block/crystalcube_cube.json @@ -0,0 +1,20 @@ +{ + "textures": { + "particle": "#cube" + }, + "elements": [ + { + "name": "Cube", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "down": { "texture": "#cube", "uv": [ 4, 4, 12, 12 ] }, + "up": { "texture": "#cube", "uv": [ 4, 4, 12, 12 ] }, + "north": { "texture": "#cube", "uv": [ 4, 4, 12, 12 ] }, + "south": { "texture": "#cube", "uv": [ 4, 4, 12, 12 ] }, + "west": { "texture": "#cube", "uv": [ 4, 4, 12, 12 ] }, + "east": { "texture": "#cube", "uv": [ 4, 4, 12, 12 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/item/corporeaCrystalCube.json b/src/main/resources/assets/botania/models/item/corporeaCrystalCube.json deleted file mode 100644 index 7960c6d70..000000000 --- a/src/main/resources/assets/botania/models/item/corporeaCrystalCube.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "builtin/entity" -} \ No newline at end of file diff --git a/src/main/resources/assets/botania/textures/model/crystalCube_base_bottom.png b/src/main/resources/assets/botania/textures/model/crystalCube_base_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..dba1f2d4f3bd7b90c814c3509bb8dfa9d9ad1ba9 GIT binary patch literal 354 zcmV-o0iFJdP)E`E^zwlJR0P@9C0xA%s~QMeX633{8v|KbKV zT`v3`IHOJiCm4)|9CrH(o9ckvig|f$nVfk10+g(Ub_axje1a)|o_hzP4=mt}89aSLRP5+cIG&qazm9p=h4 z62TBRzZQu511vP!Tsx_{SMa%qSTx41Z|iVkm}hnu-7uH~BGDN0W}UoQL0Mb#2zVU4 zS$fT>%rq0@6O`6}ka}+`IL==Uq%PYkF0cJm}Qux(A+`+xak9w!io?+9hplNBUwQ9dUYE&h2W%^(T znwDmAd=jhP0H9?%v}}j(xi20zM`CcK9xT>uM1;liPl`Jo?r%FJf}wo|3yt<43_Lw3 z7zTIP&HYK$B5zih0qmwt)+nKy6`pHpGOitugTr#~XY>CV?A^l5yH6y7A#QJM5%&kk z8l}JY;OWa3y?%>oR7KZUIG;=s2@hd8P3C8B9PFS!^Oo( z;P%!cqoz&0TZMYyV;BaPdrcZ~grge__L@xe4{*mh$>(;!k9N>~1Gg{Bv-4L_N&zsH zcey`snh&ieoBjb?+&B;F>r?}uVbfyo@Q|sz%VcF4?Vryl zR46Y<#czqdRFp;>iMu{8R%uQeaU_NEg8Xa;Vl5RDBPMWGsVF0MA7_j-8{Tgm-5}ee r_!@<1Xk?XQFr8s~=<0vYIClC2i65-y@}G+500000NkvXXu0mjfhJfV_ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/botania/textures/model/crystalCube_cube.png b/src/main/resources/assets/botania/textures/model/crystalCube_cube.png new file mode 100644 index 0000000000000000000000000000000000000000..967fa8b5f84efc3fbc33b2bb7d1cf96b18a3aecb GIT binary patch literal 346 zcmV-g0j2(lP)G%# z2#La5LBtj;$Xi;#)zASifHR&v`Q<#Yi?Uff)El?&C6hvJk3iFrvn(+ZcNS0&V@_K) zjlcJqO`vyBWLzrpdhYPJ46&q&8<<40jCB{J7Nme&#^&eR<>IPNvo)bDB*S=#+j_=5 z)}gxv5aygof5mhZ^I36tIW$O~Mx2QXW91{YK;10t?>X(SCC#3~eVilTPta5!FEYvN z*7g^&hDLdn(D4M9>jfh5aXbgN6H{KmY&$ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/botania/textures/model/crystalCube_stand.png b/src/main/resources/assets/botania/textures/model/crystalCube_stand.png new file mode 100644 index 0000000000000000000000000000000000000000..7c103b9498baa135fa33f92a66e480aca4ee2a56 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf7Wj#Y|c4f%FVt@-&wry;Ix9RY{%8Q6)rnQ>-1rOjEpu1=TInC10G<%r+UpxNvK{fXw^H$A%F)jxZW?5#y=_ZJ$b zE?vL*<)H=D0Uc)HNiW@I%$cFne*fmL{14f@cF*{ZT*+%`Ee_)WdV#^y)z4*}Q$iB} D;RI<@ literal 0 HcmV?d00001