Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mod.topazmod.Spikes;
- import org.lwjgl.opengl.GL11;
- import net.minecraft.world.World;
- import net.mod.topazmod.Reference;
- import net.mod.topazmod.TopazMod;
- import net.mod.topazmod.init.BlockMod;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.IIcon;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.client.model.ModelRenderer;
- import net.minecraft.client.model.ModelBase;
- import net.minecraft.client.Minecraft;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.BlockContainer;
- import net.minecraft.block.Block;
- 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 java.util.List;
- import java.util.Random;
- import cpw.mods.fml.relauncher.SideOnly;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.common.registry.GameRegistry;
- import cpw.mods.fml.common.event.FMLServerStartingEvent;
- import cpw.mods.fml.common.event.FMLPreInitializationEvent;
- import cpw.mods.fml.client.registry.ClientRegistry;
- public class SpikeTopaze
- {
- public SpikeTopaze() {
- }
- public static BlockTopazeSpikes block;
- public static Object instance;
- public int addFuel(ItemStack fuel) {
- return 0;
- }
- public void serverLoad(FMLServerStartingEvent event) {
- }
- public void preInit(FMLPreInitializationEvent event) {
- GameRegistry.registerBlock(block, "TopazeSpikes");
- }
- public void registerRenderers() {
- ClientRegistry.bindTileEntitySpecialRenderer(SpikeTopaze.TileEntityCustom.class,
- new SpikeTopaze.TileEntityCustomRenderer());
- }
- public void load() {
- GameRegistry.registerTileEntity(SpikeTopaze.TileEntityCustom.class, "tileEntityTopazeSpikes");
- }
- static {
- block = (BlockTopazeSpikes) (new BlockTopazeSpikes().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F).setBlockName("TopazeSpikes")
- .setBlockTextureName("null").setLightOpacity(0).setStepSound(Block.soundTypeStone).setCreativeTab(TopazMod.topatab));
- block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
- Block.blockRegistry.addObject(178, "TopazeSpikes", block);
- block.setHarvestLevel("pickaxe", 0);
- }
- static class BlockTopazeSpikes extends BlockContainer {
- int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
- Random field_149942_b = new Random();
- IIcon gor = null, dol = null, st1 = null, st2 = null, st3 = null, st4 = null;
- boolean red = false;
- protected BlockTopazeSpikes() {
- super(Material.ground);
- }
- public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
- {
- if (((entity instanceof EntityLivingBase)) && (!world.isRemote)) {
- ((EntityLivingBase)entity).attackEntityFrom(DamageSource.drown, 8F);
- }
- }
- public void onBlockAdded(World world, int i, int j, int k) {
- EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
- if (entity != null && world != null) {
- int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
- world.setBlockMetadataWithNotify(i, j, k, le, 2);
- }
- world.scheduleBlockUpdate(i, j, k, this, this.tickRate(world));
- }
- public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
- return red ? 1 : 0;
- }
- @Override
- public TileEntity createNewTileEntity(World var1, int var2) {
- return new TileEntityCustom();
- }
- @SideOnly(Side.CLIENT)
- @Override
- public IIcon getIcon(int i, int par2) {
- if (i == 0)
- return gor;
- else if (i == 1)
- return dol;
- else if (i == 2)
- return st1;
- else if (i == 3)
- return st2;
- else if (i == 4)
- return st4;
- else if (i == 5)
- return st3;
- else
- return gor;
- }
- @SideOnly(Side.CLIENT)
- @Override
- public void registerBlockIcons(IIconRegister reg) {
- this.gor = reg.registerIcon("onyx_ore");
- this.dol = reg.registerIcon("0");
- this.st1 = reg.registerIcon("0");
- this.st2 = reg.registerIcon("0");
- this.st3 = reg.registerIcon("0");
- this.st4 = reg.registerIcon("0");
- }
- public boolean isOpaqueCube() {
- return false;
- }
- public boolean renderAsNormalBlock() {
- return false;
- }
- public int getRenderType() {
- return -1;
- }
- @Override
- public int tickRate(World world) {
- return 10;
- }
- public int quantityDropped(Random par1Random) {
- return 1;
- }
- public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
- {
- int l = determineOrientation(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_);
- p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2);
- }
- public static int determineOrientation(World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_)
- {
- if (MathHelper.abs((float)p_150071_4_.posX - (float)p_150071_1_) < 2.0F && MathHelper.abs((float)p_150071_4_.posZ - (float)p_150071_3_) < 2.0F)
- {
- double d0 = p_150071_4_.posY + 1.82D - (double)p_150071_4_.yOffset;
- if (d0 - (double)p_150071_2_ > 2.0D)
- {
- return 1;
- }
- if ((double)p_150071_2_ - d0 > 0.0D)
- {
- return 0;
- }
- }
- int l = MathHelper.floor_double((double)(p_150071_4_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
- return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
- }
- public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity)
- {
- this.setBlockBounds(0.3F, 0.3F, 0.3F, 0.75F, 0.75F, 0.75F);
- super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity);
- }
- }
- public static class TileEntityCustom extends TileEntity {
- private byte direction;
- @Override
- public void readFromNBT(NBTTagCompound compound)
- {
- super.readFromNBT(compound);
- this.direction = compound.getByte("Direction");
- }
- public void writeToNBT(NBTTagCompound compound)
- {
- super.writeToNBT(compound);
- compound.setByte("Direction", this.direction);
- }
- public byte getDirection()
- {
- return direction;
- }
- public void setDirection(byte direction)
- {
- this.direction = direction;
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- }
- public Packet getDescriptionPacket()
- {
- NBTTagCompound compound = new NBTTagCompound();
- this.writeToNBT(compound);
- return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, compound);
- }
- public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
- {
- this.readFromNBT(pkt.func_148857_g());
- this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
- }
- }
- public static class TileEntityCustomRenderer extends TileEntitySpecialRenderer {
- private final Modelspike model;
- @SideOnly(Side.CLIENT)
- public TileEntityCustomRenderer() {
- this.model = new Modelspike();
- }
- @SideOnly(Side.CLIENT)
- @Override
- public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
- GL11.glPushMatrix();
- GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
- ResourceLocation textures = (new ResourceLocation(Reference.MOD_ID + ":SpikeTopaze.png"));
- Minecraft.getMinecraft().renderEngine.bindTexture(textures);
- GL11.glPushMatrix();
- GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- GL11.glPushMatrix();
- if(te.getBlockMetadata() == 0) {
- GL11.glTranslatef(0.0F, 2.0F, 0.0F);
- GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
- }
- else if(te.getBlockMetadata() == 1) {
- GL11.glTranslatef(0.0F, 0.0F, 0.0F);
- GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F);
- }
- else if(te.getBlockMetadata() == 2) {
- GL11.glTranslatef(0.0F, 1.0F, -1.0F);
- GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
- }
- else if(te.getBlockMetadata() == 3) {
- GL11.glTranslatef(0.0F, 1.0F, 1.0F);
- GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
- }
- else if(te.getBlockMetadata() == 4) {
- GL11.glTranslatef(1.0F, 1.0F, 0.0F);
- GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
- }
- else if(te.getBlockMetadata() == 5) {
- GL11.glTranslatef(-1.0F, 1.0F, 0.0F);
- GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
- }
- this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- }
- }
- // Date: 27/01/2019 16:35:58
- // Template version 1.1
- // Java generated by Techne
- // Keep in mind that you still need to fill in some blanks
- // - ZeuX
- public static class Modelspike extends ModelBase {
- // fields
- ModelRenderer Shape1;
- ModelRenderer Shape3;
- ModelRenderer Shape44545;
- ModelRenderer Shape31412;
- ModelRenderer Shape4848;
- ModelRenderer Shape34552112;
- ModelRenderer Shape451654;
- ModelRenderer Shape3415;
- ModelRenderer Shape410210;
- ModelRenderer Shape3201;
- ModelRenderer Shape45487;
- ModelRenderer Shape3789;
- ModelRenderer Shape4948512;
- ModelRenderer Shape3544554;
- ModelRenderer Shape4457781;
- ModelRenderer Shape344;
- ModelRenderer Shape478787;
- ModelRenderer Shape389587;
- ModelRenderer Shape445665;
- public Modelspike() {
- textureWidth = 64;
- textureHeight = 64;
- Shape1 = new ModelRenderer(this, 0, 0);
- Shape1.addBox(0F, 0F, 0F, 16, 1, 16);
- Shape1.setRotationPoint(-8F, 23F, -8F);
- Shape1.setTextureSize(64, 64);
- Shape1.mirror = true;
- setRotation(Shape1, 0F, 0F, 0F);
- Shape3 = new ModelRenderer(this, 0, 47);
- Shape3.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape3.setRotationPoint(-6F, 17F, -6F);
- Shape3.setTextureSize(64, 64);
- Shape3.mirror = true;
- setRotation(Shape3, 0F, 0F, 0F);
- Shape44545 = new ModelRenderer(this, 0, 30);
- Shape44545.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape44545.setRotationPoint(-7F, 22F, -7F);
- Shape44545.setTextureSize(64, 64);
- Shape44545.mirror = true;
- setRotation(Shape44545, 0F, 0F, 0F);
- Shape31412 = new ModelRenderer(this, 0, 47);
- Shape31412.addBox(0F, 0F, 0F, 1, 6, 1);
- Shape31412.setRotationPoint(5F, 16F, 0F);
- Shape31412.setTextureSize(64, 64);
- Shape31412.mirror = true;
- setRotation(Shape31412, 0F, 0F, 0F);
- Shape4848 = new ModelRenderer(this, 0, 30);
- Shape4848.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape4848.setRotationPoint(-2F, 22F, 3F);
- Shape4848.setTextureSize(64, 64);
- Shape4848.mirror = true;
- setRotation(Shape4848, 0F, 0F, 0F);
- Shape34552112 = new ModelRenderer(this, 0, 47);
- Shape34552112.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape34552112.setRotationPoint(0F, 17F, -5F);
- Shape34552112.setTextureSize(64, 64);
- Shape34552112.mirror = true;
- setRotation(Shape34552112, 0F, 0F, 0F);
- Shape451654 = new ModelRenderer(this, 0, 30);
- Shape451654.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape451654.setRotationPoint(3F, 22F, -2F);
- Shape451654.setTextureSize(64, 64);
- Shape451654.mirror = true;
- setRotation(Shape451654, 0F, 0F, 0F);
- Shape3415 = new ModelRenderer(this, 0, 47);
- Shape3415.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape3415.setRotationPoint(0F, 17F, 5F);
- Shape3415.setTextureSize(64, 64);
- Shape3415.mirror = true;
- setRotation(Shape3415, 0F, 0F, 0F);
- Shape410210 = new ModelRenderer(this, 0, 30);
- Shape410210.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape410210.setRotationPoint(-2F, 22F, -7F);
- Shape410210.setTextureSize(64, 64);
- Shape410210.mirror = true;
- setRotation(Shape410210, 0F, 0F, 0F);
- Shape3201 = new ModelRenderer(this, 0, 47);
- Shape3201.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape3201.setRotationPoint(-5F, 17F, -1F);
- Shape3201.setTextureSize(64, 64);
- Shape3201.mirror = true;
- setRotation(Shape3201, 0F, 0F, 0F);
- Shape45487 = new ModelRenderer(this, 0, 30);
- Shape45487.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape45487.setRotationPoint(-2F, 22F, -2F);
- Shape45487.setTextureSize(64, 64);
- Shape45487.mirror = true;
- setRotation(Shape45487, 0F, 0F, 0F);
- Shape3789 = new ModelRenderer(this, 0, 47);
- Shape3789.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape3789.setRotationPoint(4F, 18F, 4F);
- Shape3789.setTextureSize(64, 64);
- Shape3789.mirror = true;
- setRotation(Shape3789, 0F, 0F, 0F);
- Shape4948512 = new ModelRenderer(this, 0, 30);
- Shape4948512.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape4948512.setRotationPoint(-7F, 22F, -2F);
- Shape4948512.setTextureSize(64, 64);
- Shape4948512.mirror = true;
- setRotation(Shape4948512, 0F, 0F, 0F);
- Shape3544554 = new ModelRenderer(this, 0, 47);
- Shape3544554.addBox(0F, 0F, 0F, 1, 7, 1);
- Shape3544554.setRotationPoint(0F, 15F, 0F);
- Shape3544554.setTextureSize(64, 64);
- Shape3544554.mirror = true;
- setRotation(Shape3544554, 0F, 0F, 0F);
- Shape4457781 = new ModelRenderer(this, 0, 30);
- Shape4457781.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape4457781.setRotationPoint(-7F, 22F, 3F);
- Shape4457781.setTextureSize(64, 64);
- Shape4457781.mirror = true;
- setRotation(Shape4457781, 0F, 0F, 0F);
- Shape344 = new ModelRenderer(this, 0, 47);
- Shape344.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape344.setRotationPoint(-5F, 18F, 4F);
- Shape344.setTextureSize(64, 64);
- Shape344.mirror = true;
- setRotation(Shape344, 0F, 0F, 0F);
- Shape478787 = new ModelRenderer(this, 0, 30);
- Shape478787.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape478787.setRotationPoint(3F, 22F, -7F);
- Shape478787.setTextureSize(64, 64);
- Shape478787.mirror = true;
- setRotation(Shape478787, 0F, 0F, 0F);
- Shape389587 = new ModelRenderer(this, 0, 47);
- Shape389587.addBox(0F, 0F, 0F, 1, 5, 1);
- Shape389587.setRotationPoint(4F, 19F, -5F);
- Shape389587.setTextureSize(64, 64);
- Shape389587.mirror = true;
- setRotation(Shape389587, 0F, 0F, 0F);
- Shape445665 = new ModelRenderer(this, 0, 30);
- Shape445665.addBox(0F, 0F, 0F, 4, 1, 4);
- Shape445665.setRotationPoint(3F, 22F, 3F);
- Shape445665.setTextureSize(64, 64);
- Shape445665.mirror = true;
- setRotation(Shape445665, 0F, 0F, 0F);
- }
- public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
- super.render(entity, f, f1, f2, f3, f4, f5);
- setRotationAngles(f, f1, f2, f3, f4, f5, entity);
- Shape1.render(f5);
- Shape3.render(f5);
- Shape44545.render(f5);
- Shape31412.render(f5);
- Shape4848.render(f5);
- Shape34552112.render(f5);
- Shape451654.render(f5);
- Shape3415.render(f5);
- Shape410210.render(f5);
- Shape3201.render(f5);
- Shape45487.render(f5);
- Shape3789.render(f5);
- Shape4948512.render(f5);
- Shape3544554.render(f5);
- Shape4457781.render(f5);
- Shape344.render(f5);
- Shape478787.render(f5);
- Shape389587.render(f5);
- Shape445665.render(f5);
- }
- private void setRotation(ModelRenderer model, float x, float y, float z) {
- model.rotateAngleX = x;
- model.rotateAngleY = y;
- model.rotateAngleZ = z;
- }
- public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
- super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement