Priliminary test for animation and render

This commit is contained in:
JackCarterSmith 2018-03-25 17:49:04 +02:00
parent c7d08045d8
commit e6a08409da
9 changed files with 178 additions and 72 deletions

View File

@ -2,12 +2,10 @@ package fr.jackcartersmith.orbsat.client;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import fr.jackcartersmith.orbsat.OrbitalSatellite;
import fr.jackcartersmith.orbsat.client.handler.ClientEventHandler;
import fr.jackcartersmith.orbsat.client.handler.ParticleHandler;
@ -20,10 +18,7 @@ import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

View File

@ -59,10 +59,10 @@ public class ModelDefender extends ModelBase {
this.setRotateAngle(this.Shape6, 0.0F, 0.0F, 0.0F);
this.Shape7 = new ModelRenderer(this, 85, 0);
this.Shape7.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6);
this.Shape7.setRotationPoint(0.0F, -3.0F, 0.0F);
this.Shape7.setRotationPoint(0.0F, -3.5F, 0.0F);
this.Shape7.setTextureSize(128, 128);
this.Shape7.mirror = true;
this.setRotateAngle(this.Shape7, ((float)Math.PI / 4F), 0.0F, ((float)Math.PI / 4F));
this.setRotateAngle(this.Shape7, ((float)Math.sin(0)), (float)Math.sin(Math.PI/2), (float)Math.sin(3*Math.PI/2));
this.Shape8 = new ModelRenderer(this, 10, 26);
this.Shape8.addBox(-3.0F, 0.0F, -3.0F, 6, 2, 6);
this.Shape8.setRotationPoint(0.0F, 20.0F, 0.0F);
@ -72,7 +72,7 @@ public class ModelDefender extends ModelBase {
}
@Override
public void render(Entity entity, float embitterRotation, float brightness, float x, float y, float z, float scale) {
public void render(Entity entity, float rotation, float brightness, float x, float y, float z, float scale) {
this.Shape1.render(scale);
this.Shape2.render(scale);
this.Shape3.render(scale);
@ -80,17 +80,21 @@ public class ModelDefender extends ModelBase {
this.Shape5.render(scale);
this.Shape6.render(scale);
this.Shape8.render(scale);
}
public void renderCrystal(Entity entity, float rotation, float brightness, float x, float y, float z, float scale) {
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
float lastBrightnessY = OpenGlHelper.lastBrightnessY;
float b = brightness * 200F;
float colour = Math.min(2F, (brightness * 2F) + 0.5F);
if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b));
GL11.glColor4f(colour, colour, colour, 1F);
GL11.glColor4f(colour*10F, colour*0F, colour*20F, 0.9F);
this.Shape7.render(scale);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glDisable(GL11.GL_BLEND);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING);
}

View File

@ -39,6 +39,7 @@ public class RenderDefender implements IItemRenderer{
ResourceHandler.bindResource("textures/models/defender.png");
RenderTileDefender.modelDefender.render(null, 1F, 0F, 0F, 0F, 0F, scale);
RenderTileDefender.modelDefender.renderCrystal(null, 1F, 1F, 0F, 0F, 0F, scale);
GL11.glPopMatrix();
}
}

View File

@ -45,7 +45,19 @@ public class RenderTileDefender extends TileEntitySpecialRenderer {
*/
ResourceHandler.bindResource("textures/models/defender.png");
modelDefender.render(null, tile.modelIllumination, 0F, 0F, 0F, 0F, scale);
modelDefender.render(null, 0F, 0F, 0F, 0F, 0F, scale);
GL11.glEnable(GL11.GL_BLEND);
//float rotation = tile.rotation + (partialTick * tile.rotationSpeed);
//GL11.glRotatef(tile.rotation + (partialTick * tile.rotationSpeed), 0F, 0F, 1F);
//GL11.glRotatef(-tile.rotation + (partialTick * tile.rotationSpeed), 0F, 0F, 1F);
//modelDefender.Shape7.rotateAngleY = tile.rotation * 90.0F;
//modelDefender.Shape7.rotateAngleZ = tile.rotation * 90.0F;
modelDefender.Shape7.rotateAngleY = (float) (-Math.sin(tile.rotation));
modelDefender.Shape7.rotateAngleZ = (float) (Math.sin(-2*Math.PI/3+tile.rotation));
modelDefender.Shape7.rotateAngleX = (float) (Math.sin(2*Math.PI/3+tile.rotation));
modelDefender.renderCrystal(null, 0F, tile.modelIllumination, 0F, 0F, 0F, scale);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}

View File

@ -5,8 +5,6 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import fr.jackcartersmith.orbsat.OrbitalSatellite;
@ -14,13 +12,10 @@ import fr.jackcartersmith.orbsat.client.gui.OSGuiHandler;
import fr.jackcartersmith.orbsat.common.handler.FMLEventHandler;
import fr.jackcartersmith.orbsat.common.lib.OSConstants;
import fr.jackcartersmith.orbsat.common.lib.OSRefs;
import fr.jackcartersmith.orbsat.common.network.TileObjectPacket;
import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
import fr.jackcartersmith.orbsat.common.utils.OSLogHelper;
import net.minecraft.client.audio.ISound;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
public class CommonProxy {
public void preInit(FMLPreInitializationEvent event) {
@ -52,6 +47,8 @@ public class CommonProxy {
public void initializeNetwork() {
OrbitalSatellite.network = NetworkRegistry.INSTANCE.newSimpleChannel(OrbitalSatellite.networkChannelName);
OrbitalSatellite.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 0, Side.SERVER);
OrbitalSatellite.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 1, Side.CLIENT);
//OrbitalSatellite.network.registerMessage(OBNetwork.Handler.class, OBNetwork.class, 1, Side.SERVER);
//OrbitalSatellite.network.registerMessage(OBNetworkClient.Handler.class, OBNetworkClient.class, 2, Side.CLIENT);

View File

@ -1,7 +1,5 @@
package fr.jackcartersmith.orbsat.common.blocks;
import java.util.List;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fr.jackcartersmith.orbsat.OrbitalSatellite;
@ -12,43 +10,112 @@ import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class Defender extends BlockCustomDrop {
public class Defender extends BlockOS {
public Defender() {
super(Material.iron);
this.setBlockName(OSStrings.defenderName);
this.setCreativeTab(OrbitalSatellite.OSCreaTab);
this.setStepSound(soundTypeStone);
this.setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f);
OSBlocks.register(this);
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
blockIcon = iconRegister.registerIcon(OSRefs.RESOURCESPREFIX + "machine_side");
blockIcon = iconRegister.registerIcon(OSRefs.RESOURCESPREFIX + "machine");
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileDefender();
public void setBlockBoundsBasedOnState(IBlockAccess access, int x, int y, int z) {
/*
TileDefender tile = access.getTileEntity(x, y, z) instanceof TileDefender ? (TileDefender) access.getTileEntity(x, y, z) : null;
if (tile != null) {
switch (tile.facingDirection) {
case 0:
this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F);
break;
case 1:
this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F);
break;
case 2:
this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F);
break;
case 3:
this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F);
break;
case 4:
this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F);
break;
case 5:
this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F);
break;
}
}
*/
this.setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F);
super.setBlockBoundsBasedOnState(access, x, y, z);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
/*
TileDefender tile = world.getTileEntity(x, y, z) instanceof TileTileDefender ? (TileTileDefender) world.getTileEntity(x, y, z) : null;
if (tile != null) {
switch (tile.facingDirection) {
case 0:
this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F);
break;
case 1:
this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F);
break;
case 2:
this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F);
break;
case 3:
this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F);
break;
case 4:
this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F);
break;
case 5:
this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F);
break;
}
}
*/
this.setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
/*
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int d = Utils.determineOrientation(x, y, z, entity);
TileReactorEnergyInjector tile = (TileReactorEnergyInjector) world.getTileEntity(x, y, z);
tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal();
tile.onPlaced();
}
*/
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) {
if (!world.isRemote) {
//FMLNetworkHandler.openGui(player, OrbitalSatellite.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z);
TileDefender tile = (TileDefender) world.getTileEntity(x, y, z);
if (tile != null) {
if (!world.isRemote) {
player.addChatComponentMessage(new ChatComponentText(Float.toString(tile.rotation)));
//FMLNetworkHandler.openGui(player, OrbitalSatellite.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z);
}
}
world.markBlockForUpdate(x, y, z);
return true;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType() {
return -1;
@ -63,29 +130,14 @@ public class Defender extends BlockCustomDrop {
public boolean renderAsNormalBlock() {
return false;
}
@Override
protected boolean dropInventory() {
public boolean hasTileEntity(int metadata) {
return true;
}
@Override
protected boolean hasCustomDropps() {
return false;
}
@Override
protected void getCustomTileEntityDrops(TileEntity te, List<ItemStack> droppes) {
}
@Override
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) {
return false;
}
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return true;
public TileEntity createTileEntity(World world, int metadata) {
return new TileDefender();
}
}

View File

@ -1,54 +1,99 @@
package fr.jackcartersmith.orbsat.common.tileentities;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
//public class TileDefender extends TileObjectSync implements IEnergyReceiver, ISidedInventory {
public class TileDefender extends TileObjectSync {
public float modelIllumination = 1F;
public class TileDefender extends TileEntity {
public float modelIllumination = 30F;
public int facingDirection = ForgeDirection.UP.ordinal();
public boolean isValid = false;
public int tick = 0;
public boolean running = false;
public boolean runningCach = false;
private int tick = 0;
public float rotation = 0;
public float rotationSpeed = 0;
private float targetSpeed = 0;
//@SideOnly(Side.CLIENT)
//private ParticleReactorBeam beam;
@Override
public Packet getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
//masterLocation.writeToNBT(compound, "Master");
compound.setInteger("Facing", facingDirection);
//compound.setBoolean("IsValid", isValid);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
public void updateEntity() {
//rotation += 1.0E-2F * (float)this.getCurrentCharge();
rotation += 1.0E-1F;
if ((double)rotation >= Math.PI)
{
rotation = (float)(-Math.PI);
}
/*
targetSpeed = 1F;
if (rotationSpeed < targetSpeed) rotationSpeed += 0.05F;
else if (rotationSpeed > targetSpeed) rotationSpeed -= 0.05F;
if (targetSpeed == 0 && rotationSpeed < 0) rotationSpeed = 0;
rotation += rotationSpeed;
*/
}
/*
private boolean tryStartOrStop() {
if (items[0] != null && items[0].stackSize == 1 && items[0] != null && items[0].getItem() instanceof IEnergyContainerItem) {
IEnergyContainerItem item = (IEnergyContainerItem) items[0].getItem();
if (item.getEnergyStored(items[0]) < item.getMaxEnergyStored(items[0])) {
running = true;
} else {
running = false;
}
} else {
running = false;
}
return running;
}
*/
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tagCompound = new NBTTagCompound();
this.writeToNBT(tagCompound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound compound = pkt.func_148857_g();
//masterLocation.readFromNBT(compound, "Master");
facingDirection = compound.getInteger("Facing");
//isValid = compound.getBoolean("IsValid");
super.onDataPacket(net, pkt);
readFromNBT(pkt.func_148857_g());
}
/*
public void detectAndSendChanges(boolean sendAnyway) {
if (runningCach != running || sendAnyway) {
runningCach = (Boolean) sendObjectToClient(OSRefs.BOOLEAN_ID, 0, running);
}
}
@SideOnly(Side.CLIENT)
@Override
public void receiveObjectFromServer(int index, Object object) {
if (index == 0) running = (Boolean) object;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
/*
masterLocation.writeToNBT(compound, "Master");
compound.setInteger("Facing", facingDirection);
compound.setBoolean("IsValid", isValid);
compound.setInteger("RedstoneMode", redstoneMode);
*/
}
*/
@Override
public void readFromNBT(NBTTagCompound compound) {

View File

@ -5,7 +5,7 @@ import fr.jackcartersmith.orbsat.OrbitalSatellite;
import fr.jackcartersmith.orbsat.common.network.TileObjectPacket;
import net.minecraft.tileentity.TileEntity;
public class TileObjectSync extends TileEntity{
public abstract class TileObjectSync extends TileEntity{
/**
* Sends a primitive to the client in the form of an object
*/

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB