This commit is contained in:
Bernhard Bonigl committed 2014-09-10 00:45:22 +02:00
commit 91e01087ee
8 files changed
+315 -11

No files matched your search

@@ -1,9 +1,12 @@
package tconstruct.items.tools;
import cpw.mods.fml.relauncher.*;
import net.minecraft.item.Item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.*;
import net.minecraft.world.World;
import tconstruct.library.tools.Weapon;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.EquipLogic;
public class BattleSign extends Weapon
{
@@ -117,4 +120,64 @@ public class BattleSign extends Weapon
{
return "battlesign";
}
@Override
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
{
if (side == 0 || !player.isSneaking())
{
return false;
}
else if (!world.getBlock(x, y, z).getMaterial().isSolid())
{
return false;
}
else
{
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
if (!player.canPlayerEdit(x, y, z, side, stack))
{
return false;
}
else if (!TinkerTools.battlesignBlock.canPlaceBlockAt(world, x, y, z))
{
return false;
}
else
{
world.setBlock(x, y, z, TinkerTools.battlesignBlock, 0, 3);
TinkerTools.battlesignBlock.onBlockPlacedBy(world, x, y, z, player, stack);
EquipLogic logic = (EquipLogic) world.getTileEntity(x, y, z);
logic.setEquipmentItem(stack);
--stack.stackSize;
return true;
}
}
}
}
@@ -138,10 +138,7 @@ public class TinkerTools
TinkerTools.furnaceSlab = new FurnaceSlab(Material.rock).setBlockName("FurnaceSlab");
TinkerTools.heldItemBlock = new EquipBlock(Material.wood).setBlockName("Frypan");
/* battlesignBlock = new BattlesignBlock(PHConstruct.battlesignBlock).setUnlocalizedName("Battlesign");
GameRegistry.registerBlock(battlesignBlock, "BattlesignBlock");
ameRegistry.registerTileEntity(BattlesignLogic.class, "BattlesignLogic");*/
TinkerTools.battlesignBlock = new BattlesignBlock(Material.wood).setBlockName("Battlesign");
TinkerTools.craftedSoil = new SoilBlock().setLightOpacity(0).setBlockName("TConstruct.Soil");
TinkerTools.craftedSoil.stepSound = Block.soundTypeGravel;
@@ -160,6 +157,8 @@ public class TinkerTools
GameRegistry.registerTileEntity(FurnaceLogic.class, "TConstruct.Furnace");
GameRegistry.registerBlock(TinkerTools.heldItemBlock, "HeldItemBlock");
GameRegistry.registerTileEntity(FrypanLogic.class, "FrypanLogic");
GameRegistry.registerBlock(TinkerTools.battlesignBlock, "BattleSignBlock");
GameRegistry.registerTileEntity(BattlesignLogic.class, "BattlesignLogic");
GameRegistry.registerBlock(TinkerTools.craftedSoil, CraftedSoilItemBlock.class, "CraftedSoil");
@@ -4,6 +4,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import mantle.client.MProxyClient;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.*;
import net.minecraft.item.ItemStack;
@@ -45,6 +46,7 @@ public class ToolProxyClient extends ToolProxyCommon
{
RenderingRegistry.registerBlockHandler(new TableRender());
RenderingRegistry.registerBlockHandler(new FrypanRender());
RenderingRegistry.registerBlockHandler(new BattlesignRender());
RenderingRegistry.registerEntityRenderingHandler(LaunchedPotion.class, new LaunchedItemRender(Items.potionitem, 16384));
RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRenderCustom());
@@ -56,6 +58,8 @@ public class ToolProxyClient extends ToolProxyCommon
ToolCoreRenderer renderer = new ToolCoreRenderer(true);
MinecraftForgeClient.registerItemRenderer(TinkerTools.arrow, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerTools.dagger, renderer);
TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(BattlesignLogic.class, new BattlesignTesr());
}
public void registerManualIcons ()
@@ -0,0 +1,99 @@
package tconstruct.tools.blocks;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.*;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.world.*;
import tconstruct.tools.logic.BattlesignLogic;
import tconstruct.tools.model.BattlesignRender;
public class BattlesignBlock extends EquipBlock
{
public BattlesignBlock(Material material)
{
super(material);
this.setBlockBounds(0.45F, 0F, 0.45F, 0.55F, 1F, 0.55F);
}
@Override
public int getRenderType ()
{
return BattlesignRender.battlesignModelID;
}
@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
return new BattlesignLogic();
}
@Override
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int newMeta = 0;
switch (i3)
{
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
}
@Override
public void setBlockBoundsBasedOnState (IBlockAccess blockAccess, int x, int y, int z)
{
switch (blockAccess.getBlockMetadata(x, y, z))
{
case 0:
setBlockBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F);
break;
case 1:
setBlockBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F);
break;
case 2:
setBlockBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F);
break;
case 3:
setBlockBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F);
break;
}
}
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
{
setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
setBlockBounds(0.45F, 0F, 0.45F, 0.55F, 1F, 0.55F);
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
this.setBlockBoundsForItemRender();
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
return new BattlesignLogic();
}
}
@@ -16,7 +16,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.world.*;
import tconstruct.TConstruct;
import tconstruct.items.tools.FryingPan;
import tconstruct.library.TConstructRegistry;
import tconstruct.tools.ToolProxyCommon;
import tconstruct.tools.logic.*;
@@ -202,14 +201,12 @@ public class EquipBlock extends InventoryBlock
{
TileEntity te = blockAccess.getTileEntity(x, y, z);
if (te instanceof FrypanLogic)
if (te instanceof EquipLogic)
{
FrypanLogic logic = (FrypanLogic) te;
EquipLogic logic = (EquipLogic) te;
ItemStack stack = logic.getEquipmentItem();
if (stack != null && stack.getItem() instanceof FryingPan)
if (stack != null)
{
FryingPan pan = (FryingPan) stack.getItem();
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("InfiTool");
if (tag != null)
@@ -2,6 +2,9 @@ package tconstruct.tools.logic;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
/* Slots
* 0: Frying pan item
@@ -56,4 +59,20 @@ public abstract class EquipLogic extends InventoryLogic
{
return slot != 0 ? inventory[slot] != null : false;
}
@Override
public S35PacketUpdateTileEntity getDescriptionPacket ()
{
NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
return packet;
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt)
{
this.readFromNBT(pkt.func_148857_g());
}
}
@@ -0,0 +1,59 @@
package tconstruct.tools.model;
import cpw.mods.fml.client.registry.*;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
public class BattlesignRender implements ISimpleBlockRenderingHandler
{
public static int battlesignModelID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
// Inventory should be an item. This is not here!
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
renderer.setRenderBounds(0.45F, 0.0F, 0.45F, 0.55F, 1.125F, 0.55F);
renderer.renderStandardBlock(block, x, y, z);
renderFace(world, x, y, z, block, renderer);
return true;
}
public void renderFace (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer)
{
switch (world.getBlockMetadata(x, y, z))
{
case 0:
renderer.setRenderBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F);
break;
case 1:
renderer.setRenderBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F);
break;
case 2:
renderer.setRenderBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F);
break;
case 3:
renderer.setRenderBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F);
break;
}
renderer.renderStandardBlock(block, x, y, z);
}
@Override
public boolean shouldRender3DInInventory (int modelid)
{
return true;
}
@Override
public int getRenderId ()
{
return battlesignModelID;
}
}
@@ -0,0 +1,64 @@
package tconstruct.tools.model;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
public class BattlesignTesr extends TileEntitySpecialRenderer
{
@Override
public void renderTileEntityAt (TileEntity te, double x, double y, double z, float something)
{
GL11.glPushMatrix();
float f = 0.016666668F * 0.6666667F;
GL11.glTranslated(x, y, z);
GL11.glScalef(f, -f, f);
// GL11.glRotatef(180F, 0F, 0F, 1F);
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
switch (te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord))
{
case 0:
GL11.glRotatef(-90F, 0F, 1F, 0F);
GL11.glTranslatef(5F, -97F, -37F);
break;
case 1:
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glTranslatef(-85F, -97F, 53F);
break;
case 2:
GL11.glTranslatef(5F, -97F, 53F);
break;
case 3:
GL11.glRotatef(180F, 0F, 1F, 0F);
GL11.glTranslatef(-85F, -97F, -37F);
break;
}
String strings[] = { "Chicken nuggets", "Curly fries", "fuj1n", "mDiyo", "Frosty_Chicken" };
float lum = calcLuminance(te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord).colorMultiplier(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord));
for (int i = 0; i < strings.length; i++)
{
fr.drawString((lum >= 35F ? "" : lum >= 31F ? EnumChatFormatting.DARK_GRAY : EnumChatFormatting.WHITE) + strings[i], -fr.getStringWidth(strings[i]) / 2 + 40, 10 * i, 0);
}
GL11.glPopMatrix();
}
private float calcLuminance (int rgb)
{
int r = (rgb & 0xff0000) >> 16;
int g = (rgb & 0xff00) >> 8;
int b = (rgb & 0xff);
return (r * 0.299f + g * 0.587f + b * 0.114f) / 3;
}
}