mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-28 07:55:48 +00:00
new Feature
This commit is contained in:
1 parent
c432156fc0
commit
00a57c960c
18 files changed
+576
-53
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package com.brandon3055.draconicevolution.client.keybinding;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 14/08/2014.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class KeyBindings {
|
||||
public static KeyBinding placeItem;
|
||||
|
||||
public static void init() {
|
||||
placeItem = new KeyBinding("key.pong", Keyboard.KEY_P, "key.categories."+ References.MODID);
|
||||
ClientRegistry.registerKeyBinding(placeItem);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.brandon3055.draconicevolution.client.keybinding;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.core.network.PlacedItemPacket;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.ToolHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 14/08/2014.
|
||||
*/
|
||||
public class KeyInputHandler {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if(KeyBindings.placeItem.isPressed()) handlePlaceItemKey();
|
||||
}
|
||||
|
||||
private void handlePlaceItemKey(){
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
WorldClient world = Minecraft.getMinecraft().theWorld;
|
||||
MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 4.5D);
|
||||
if (mop != null) DraconicEvolution.channelHandler.sendToServer(new PlacedItemPacket((byte) mop.sideHit, mop.blockX, mop.blockY, mop.blockZ));
|
||||
}
|
||||
}
|
||||
+2
-20
@@ -1,37 +1,20 @@
|
||||
package com.brandon3055.draconicevolution.client.render;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.core.handler.ParticleHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemCloth;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
|
||||
|
||||
public class EnergyInfiserRenderer extends TileEntitySpecialRenderer
|
||||
{
|
||||
@@ -52,7 +35,6 @@ public class EnergyInfiserRenderer extends TileEntitySpecialRenderer
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
//And this method actually renders your tile entity
|
||||
public void renderBlock(TileEnergyInfuser tile, World world, int x, int y, int z, Block block)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
@@ -333,6 +333,7 @@ public final class Particles {
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
moveEntity(motionX, motionY, motionZ);
|
||||
timer++;
|
||||
}
|
||||
|
||||
/**Go to target and expand with timer*/
|
||||
@@ -375,6 +376,7 @@ public final class Particles {
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
moveEntity(motionX, motionY, motionZ);
|
||||
timer++;
|
||||
}
|
||||
|
||||
/**Goes to target and Expand*/
|
||||
@@ -405,6 +407,7 @@ public final class Particles {
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
moveEntity(motionX, motionY, motionZ);
|
||||
timer++;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
package com.brandon3055.draconicevolution.client.render;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.items.MobSoul;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TilePlacedItem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/07/2014.
|
||||
*/
|
||||
public class PlacedItemRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
public PlacedItemRenderer()
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float timeSinceLastTick) {
|
||||
if (te == null || !(te instanceof TilePlacedItem)) return;
|
||||
TilePlacedItem tile = (TilePlacedItem) te;
|
||||
if (tile.getStack() == null) return;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glTranslated(x, y, z);
|
||||
renderItem(tile);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderItem(TilePlacedItem tile){
|
||||
ItemStack stack = tile.getStack();
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack);
|
||||
int meta = world.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
//itemEntity.getEntityItem().stackSize = 1;
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
boolean is3D = stack.getItem().isFull3D();
|
||||
boolean isBlock = stack.getItem() instanceof ItemBlock;
|
||||
|
||||
if (isBlock){
|
||||
GL11.glTranslatef(0.5F, 0.25F, 0.5F);
|
||||
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
||||
metaAdjustBlock(meta);
|
||||
GL11.glRotatef(tile.rotation, 0F, 1F, 0F);
|
||||
}else if (is3D || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow){
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
GL11.glRotatef(90F, -1F, 0F, 0F);
|
||||
GL11.glTranslatef(0.25F, -0.45F, 0.02F);
|
||||
metaAdjustItemTool(meta);
|
||||
GL11.glTranslatef(0.0F, 0.21F, 0.0F);
|
||||
GL11.glRotatef(tile.rotation, 0F, 0F, 1F);
|
||||
GL11.glTranslatef(0.0F, -0.21F, 0.0F);
|
||||
} else if (stack.getItem() instanceof MobSoul) {
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.3F, 0.5F);
|
||||
}else {
|
||||
GL11.glRotatef(90F, -1F, 0F, 0F);
|
||||
GL11.glTranslatef(0.5F, -0.65F, 0.02F);
|
||||
metaAdjustItem(meta);
|
||||
GL11.glTranslatef(0.0F, 0.18F, 0.0F);
|
||||
GL11.glRotatef(tile.rotation, 0F, 0F, 1F);
|
||||
GL11.glTranslatef(0.0F, -0.18F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
private void metaAdjustItemTool(int meta){
|
||||
switch (meta){
|
||||
case 0:
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(0.0F, 0.0F, -0.46F);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(0.0F, 0.02F, -0.03F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glTranslatef(0.0F, 0.02F, -0.43F);
|
||||
break;
|
||||
case 4:
|
||||
GL11.glRotatef(90F, 0F, -1F, 0F);
|
||||
GL11.glRotatef(90F, 0F, 0F, -1F);
|
||||
GL11.glTranslatef(-0.205F, 0.02F, -0.23F);
|
||||
break;
|
||||
case 5:
|
||||
GL11.glRotatef(90F, 0F, -1F, 0F);
|
||||
GL11.glRotatef(90F, 0F, 0F, -1F);
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(0.223F, 0.0F, -0.23F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void metaAdjustItem(int meta){
|
||||
switch (meta){
|
||||
case 0:
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(0.0F, 0.0F, -0.96F);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(0.0F, 0.32F, -0.33F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glTranslatef(0.0F, 0.3F, -0.63F);
|
||||
break;
|
||||
case 4:
|
||||
GL11.glRotatef(90F, 0F, -1F, 0F);
|
||||
GL11.glRotatef(90F, 0F, 0F, -1F);
|
||||
GL11.glTranslatef(-0.17F, 0.302F, -0.475F);
|
||||
break;
|
||||
case 5:
|
||||
GL11.glRotatef(90F, 0F, -1F, 0F);
|
||||
GL11.glRotatef(90F, 0F, 0F, -1F);
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(0.15F, 0.3F, -0.475F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void metaAdjustBlock(int meta){
|
||||
switch (meta){
|
||||
case 0:
|
||||
GL11.glTranslatef(0.0F, 0.51F, 0.0F);
|
||||
GL11.glRotatef(180F, 0F, 0F, 1F);
|
||||
break;
|
||||
case 1:
|
||||
GL11.glTranslatef(0.0F, -0.17F, 0.0F);
|
||||
break;
|
||||
case 2:
|
||||
GL11.glTranslatef(-0.0F, 0.17F, 0.34F);
|
||||
GL11.glRotatef(90F, -1F, 0F, 0F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef(0.0F, 0.17F, -0.34F);
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
break;
|
||||
case 4:
|
||||
GL11.glTranslatef(0.34F, 0.17F, 0.0F);
|
||||
GL11.glRotatef(90F, 0F, 0F, 1F);
|
||||
break;
|
||||
case 5:
|
||||
GL11.glTranslatef(-0.34F, 0.17F, 0.0F);
|
||||
GL11.glRotatef(90F, 0F, 0F, -1F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-15
@@ -2,27 +2,13 @@ package com.brandon3055.draconicevolution.client.render;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemCloth;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class SoulItemRenderer implements IItemRenderer {
|
||||
private Minecraft mc;
|
||||
@@ -45,7 +31,10 @@ public class SoulItemRenderer implements IItemRenderer {
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
Entity mob = EntityList.createEntityByName(ItemNBTHelper.getString(item, "Name", "Pig"), mc.theWorld);
|
||||
|
||||
if (mob == null) {
|
||||
LogHelper.error("Invalid Mob Name:" + ItemNBTHelper.getString(item, "Name", "Pig"));
|
||||
mob = EntityList.createEntityByName("Pig", mc.theWorld);
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
@@ -89,7 +78,10 @@ public class SoulItemRenderer implements IItemRenderer {
|
||||
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
||||
GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F);
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user