Guest User

Untitled

a guest
Mar 10th, 2019
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package net.mod.topazmod.Spikes;
  3.  
  4. import org.lwjgl.opengl.GL11;
  5.  
  6. import net.minecraft.world.World;
  7. import net.mod.topazmod.Reference;
  8. import net.mod.topazmod.TopazMod;
  9. import net.mod.topazmod.init.BlockMod;
  10. import net.minecraft.world.IBlockAccess;
  11. import net.minecraft.util.ResourceLocation;
  12. import net.minecraft.util.MathHelper;
  13. import net.minecraft.util.AxisAlignedBB;
  14. import net.minecraft.util.ChatComponentText;
  15. import net.minecraft.util.DamageSource;
  16. import net.minecraft.util.IIcon;
  17. import net.minecraft.tileentity.TileEntity;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.item.ItemStack;
  20. import net.minecraft.nbt.NBTTagCompound;
  21. import net.minecraft.entity.player.EntityPlayer;
  22. import net.minecraft.entity.Entity;
  23. import net.minecraft.entity.EntityLivingBase;
  24. import net.minecraft.creativetab.CreativeTabs;
  25. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  26. import net.minecraft.client.renderer.texture.IIconRegister;
  27. import net.minecraft.client.model.ModelRenderer;
  28. import net.minecraft.client.model.ModelBase;
  29. import net.minecraft.client.Minecraft;
  30. import net.minecraft.block.material.Material;
  31. import net.minecraft.block.BlockContainer;
  32. import net.minecraft.block.Block;
  33. import net.minecraft.nbt.NBTTagCompound;
  34. import net.minecraft.network.NetworkManager;
  35. import net.minecraft.network.Packet;
  36. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  37. import net.minecraft.tileentity.TileEntity;
  38. import java.util.List;
  39. import java.util.Random;
  40.  
  41. import cpw.mods.fml.relauncher.SideOnly;
  42. import cpw.mods.fml.relauncher.Side;
  43. import cpw.mods.fml.common.registry.GameRegistry;
  44. import cpw.mods.fml.common.event.FMLServerStartingEvent;
  45. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  46. import cpw.mods.fml.client.registry.ClientRegistry;
  47.  
  48. public class SpikeTopaze
  49. {
  50. public SpikeTopaze() {
  51. }
  52.  
  53. public static BlockTopazeSpikes block;
  54.  
  55. public static Object instance;
  56.  
  57. public int addFuel(ItemStack fuel) {
  58. return 0;
  59. }
  60.  
  61. public void serverLoad(FMLServerStartingEvent event) {
  62. }
  63.  
  64. public void preInit(FMLPreInitializationEvent event) {
  65.  
  66. GameRegistry.registerBlock(block, "TopazeSpikes");
  67. }
  68.  
  69. public void registerRenderers() {
  70. ClientRegistry.bindTileEntitySpecialRenderer(SpikeTopaze.TileEntityCustom.class,
  71. new SpikeTopaze.TileEntityCustomRenderer());
  72. }
  73.  
  74. public void load() {
  75. GameRegistry.registerTileEntity(SpikeTopaze.TileEntityCustom.class, "tileEntityTopazeSpikes");
  76. }
  77.  
  78. static {
  79.  
  80. block = (BlockTopazeSpikes) (new BlockTopazeSpikes().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F).setBlockName("TopazeSpikes")
  81. .setBlockTextureName("null").setLightOpacity(0).setStepSound(Block.soundTypeStone).setCreativeTab(TopazMod.topatab));
  82. block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  83. Block.blockRegistry.addObject(178, "TopazeSpikes", block);
  84. block.setHarvestLevel("pickaxe", 0);
  85. }
  86.  
  87.  
  88.  
  89.  
  90. static class BlockTopazeSpikes extends BlockContainer {
  91.  
  92. int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
  93.  
  94. Random field_149942_b = new Random();
  95.  
  96. IIcon gor = null, dol = null, st1 = null, st2 = null, st3 = null, st4 = null;
  97.  
  98. boolean red = false;
  99.  
  100. protected BlockTopazeSpikes() {
  101. super(Material.ground);
  102.  
  103. }
  104.  
  105. public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
  106. {
  107. if (((entity instanceof EntityLivingBase)) && (!world.isRemote)) {
  108. ((EntityLivingBase)entity).attackEntityFrom(DamageSource.drown, 8F);
  109. }
  110. }
  111.  
  112. public void onBlockAdded(World world, int i, int j, int k) {
  113. EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
  114. if (entity != null && world != null) {
  115. int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  116. world.setBlockMetadataWithNotify(i, j, k, le, 2);
  117. }
  118.  
  119. world.scheduleBlockUpdate(i, j, k, this, this.tickRate(world));
  120.  
  121. }
  122.  
  123. public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
  124. return red ? 1 : 0;
  125. }
  126.  
  127. @Override
  128. public TileEntity createNewTileEntity(World var1, int var2) {
  129. return new TileEntityCustom();
  130. }
  131.  
  132. @SideOnly(Side.CLIENT)
  133. @Override
  134. public IIcon getIcon(int i, int par2) {
  135.  
  136. if (i == 0)
  137. return gor;
  138.  
  139. else if (i == 1)
  140. return dol;
  141.  
  142. else if (i == 2)
  143. return st1;
  144.  
  145. else if (i == 3)
  146. return st2;
  147.  
  148. else if (i == 4)
  149. return st4;
  150.  
  151. else if (i == 5)
  152. return st3;
  153.  
  154. else
  155. return gor;
  156.  
  157. }
  158.  
  159. @SideOnly(Side.CLIENT)
  160. @Override
  161. public void registerBlockIcons(IIconRegister reg) {
  162. this.gor = reg.registerIcon("onyx_ore");
  163. this.dol = reg.registerIcon("0");
  164. this.st1 = reg.registerIcon("0");
  165. this.st2 = reg.registerIcon("0");
  166. this.st3 = reg.registerIcon("0");
  167. this.st4 = reg.registerIcon("0");
  168. }
  169.  
  170. public boolean isOpaqueCube() {
  171. return false;
  172. }
  173.  
  174. public boolean renderAsNormalBlock() {
  175. return false;
  176. }
  177.  
  178. public int getRenderType() {
  179. return -1;
  180. }
  181.  
  182. @Override
  183. public int tickRate(World world) {
  184. return 10;
  185. }
  186.  
  187. public int quantityDropped(Random par1Random) {
  188. return 1;
  189. }
  190.  
  191.  
  192. 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_)
  193. {
  194. int l = determineOrientation(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_);
  195. p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2);
  196.  
  197.  
  198. }
  199.  
  200. public static int determineOrientation(World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_)
  201. {
  202. 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)
  203. {
  204. double d0 = p_150071_4_.posY + 1.82D - (double)p_150071_4_.yOffset;
  205.  
  206. if (d0 - (double)p_150071_2_ > 2.0D)
  207. {
  208. return 1;
  209. }
  210.  
  211. if ((double)p_150071_2_ - d0 > 0.0D)
  212. {
  213. return 0;
  214. }
  215. }
  216.  
  217. int l = MathHelper.floor_double((double)(p_150071_4_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  218. return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
  219. }
  220.  
  221. public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity)
  222. {
  223.  
  224. this.setBlockBounds(0.3F, 0.3F, 0.3F, 0.75F, 0.75F, 0.75F);
  225. super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity);
  226.  
  227.  
  228.  
  229.  
  230.  
  231. }
  232.  
  233.  
  234. }
  235.  
  236. public static class TileEntityCustom extends TileEntity {
  237. private byte direction;
  238.  
  239. @Override
  240. public void readFromNBT(NBTTagCompound compound)
  241. {
  242. super.readFromNBT(compound);
  243. this.direction = compound.getByte("Direction");
  244. }
  245.  
  246. public void writeToNBT(NBTTagCompound compound)
  247. {
  248. super.writeToNBT(compound);
  249. compound.setByte("Direction", this.direction);
  250. }
  251.  
  252. public byte getDirection()
  253. {
  254. return direction;
  255. }
  256.  
  257. public void setDirection(byte direction)
  258. {
  259. this.direction = direction;
  260. this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
  261. }
  262.  
  263. public Packet getDescriptionPacket()
  264. {
  265. NBTTagCompound compound = new NBTTagCompound();
  266. this.writeToNBT(compound);
  267. return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, compound);
  268. }
  269.  
  270. public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
  271. {
  272. this.readFromNBT(pkt.func_148857_g());
  273. this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
  274. }
  275.  
  276.  
  277.  
  278.  
  279. }
  280.  
  281.  
  282.  
  283.  
  284. public static class TileEntityCustomRenderer extends TileEntitySpecialRenderer {
  285. private final Modelspike model;
  286.  
  287. @SideOnly(Side.CLIENT)
  288. public TileEntityCustomRenderer() {
  289. this.model = new Modelspike();
  290. }
  291. @SideOnly(Side.CLIENT)
  292. @Override
  293. public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
  294.  
  295. GL11.glPushMatrix();
  296. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
  297. ResourceLocation textures = (new ResourceLocation(Reference.MOD_ID + ":SpikeTopaze.png"));
  298. Minecraft.getMinecraft().renderEngine.bindTexture(textures);
  299. GL11.glPushMatrix();
  300. GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
  301. GL11.glPushMatrix();
  302.  
  303.  
  304. if(te.getBlockMetadata() == 0) {
  305. GL11.glTranslatef(0.0F, 2.0F, 0.0F);
  306. GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
  307. }
  308. else if(te.getBlockMetadata() == 1) {
  309. GL11.glTranslatef(0.0F, 0.0F, 0.0F);
  310. GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F);
  311. }
  312. else if(te.getBlockMetadata() == 2) {
  313. GL11.glTranslatef(0.0F, 1.0F, -1.0F);
  314. GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
  315. }
  316. else if(te.getBlockMetadata() == 3) {
  317. GL11.glTranslatef(0.0F, 1.0F, 1.0F);
  318. GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
  319. }
  320. else if(te.getBlockMetadata() == 4) {
  321. GL11.glTranslatef(1.0F, 1.0F, 0.0F);
  322. GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
  323. }
  324. else if(te.getBlockMetadata() == 5) {
  325. GL11.glTranslatef(-1.0F, 1.0F, 0.0F);
  326. GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
  327. }
  328. this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  329. GL11.glPopMatrix();
  330. GL11.glPopMatrix();
  331. GL11.glPopMatrix();
  332. }
  333. }
  334.  
  335. // Date: 27/01/2019 16:35:58
  336. // Template version 1.1
  337. // Java generated by Techne
  338. // Keep in mind that you still need to fill in some blanks
  339. // - ZeuX
  340.  
  341. public static class Modelspike extends ModelBase {
  342. // fields
  343. ModelRenderer Shape1;
  344. ModelRenderer Shape3;
  345. ModelRenderer Shape44545;
  346. ModelRenderer Shape31412;
  347. ModelRenderer Shape4848;
  348. ModelRenderer Shape34552112;
  349. ModelRenderer Shape451654;
  350. ModelRenderer Shape3415;
  351. ModelRenderer Shape410210;
  352. ModelRenderer Shape3201;
  353. ModelRenderer Shape45487;
  354. ModelRenderer Shape3789;
  355. ModelRenderer Shape4948512;
  356. ModelRenderer Shape3544554;
  357. ModelRenderer Shape4457781;
  358. ModelRenderer Shape344;
  359. ModelRenderer Shape478787;
  360. ModelRenderer Shape389587;
  361. ModelRenderer Shape445665;
  362.  
  363. public Modelspike() {
  364. textureWidth = 64;
  365. textureHeight = 64;
  366.  
  367. Shape1 = new ModelRenderer(this, 0, 0);
  368. Shape1.addBox(0F, 0F, 0F, 16, 1, 16);
  369. Shape1.setRotationPoint(-8F, 23F, -8F);
  370. Shape1.setTextureSize(64, 64);
  371. Shape1.mirror = true;
  372. setRotation(Shape1, 0F, 0F, 0F);
  373. Shape3 = new ModelRenderer(this, 0, 47);
  374. Shape3.addBox(0F, 0F, 0F, 1, 5, 1);
  375. Shape3.setRotationPoint(-6F, 17F, -6F);
  376. Shape3.setTextureSize(64, 64);
  377. Shape3.mirror = true;
  378. setRotation(Shape3, 0F, 0F, 0F);
  379. Shape44545 = new ModelRenderer(this, 0, 30);
  380. Shape44545.addBox(0F, 0F, 0F, 4, 1, 4);
  381. Shape44545.setRotationPoint(-7F, 22F, -7F);
  382. Shape44545.setTextureSize(64, 64);
  383. Shape44545.mirror = true;
  384. setRotation(Shape44545, 0F, 0F, 0F);
  385. Shape31412 = new ModelRenderer(this, 0, 47);
  386. Shape31412.addBox(0F, 0F, 0F, 1, 6, 1);
  387. Shape31412.setRotationPoint(5F, 16F, 0F);
  388. Shape31412.setTextureSize(64, 64);
  389. Shape31412.mirror = true;
  390. setRotation(Shape31412, 0F, 0F, 0F);
  391. Shape4848 = new ModelRenderer(this, 0, 30);
  392. Shape4848.addBox(0F, 0F, 0F, 4, 1, 4);
  393. Shape4848.setRotationPoint(-2F, 22F, 3F);
  394. Shape4848.setTextureSize(64, 64);
  395. Shape4848.mirror = true;
  396. setRotation(Shape4848, 0F, 0F, 0F);
  397. Shape34552112 = new ModelRenderer(this, 0, 47);
  398. Shape34552112.addBox(0F, 0F, 0F, 1, 5, 1);
  399. Shape34552112.setRotationPoint(0F, 17F, -5F);
  400. Shape34552112.setTextureSize(64, 64);
  401. Shape34552112.mirror = true;
  402. setRotation(Shape34552112, 0F, 0F, 0F);
  403. Shape451654 = new ModelRenderer(this, 0, 30);
  404. Shape451654.addBox(0F, 0F, 0F, 4, 1, 4);
  405. Shape451654.setRotationPoint(3F, 22F, -2F);
  406. Shape451654.setTextureSize(64, 64);
  407. Shape451654.mirror = true;
  408. setRotation(Shape451654, 0F, 0F, 0F);
  409. Shape3415 = new ModelRenderer(this, 0, 47);
  410. Shape3415.addBox(0F, 0F, 0F, 1, 5, 1);
  411. Shape3415.setRotationPoint(0F, 17F, 5F);
  412. Shape3415.setTextureSize(64, 64);
  413. Shape3415.mirror = true;
  414. setRotation(Shape3415, 0F, 0F, 0F);
  415. Shape410210 = new ModelRenderer(this, 0, 30);
  416. Shape410210.addBox(0F, 0F, 0F, 4, 1, 4);
  417. Shape410210.setRotationPoint(-2F, 22F, -7F);
  418. Shape410210.setTextureSize(64, 64);
  419. Shape410210.mirror = true;
  420. setRotation(Shape410210, 0F, 0F, 0F);
  421. Shape3201 = new ModelRenderer(this, 0, 47);
  422. Shape3201.addBox(0F, 0F, 0F, 1, 5, 1);
  423. Shape3201.setRotationPoint(-5F, 17F, -1F);
  424. Shape3201.setTextureSize(64, 64);
  425. Shape3201.mirror = true;
  426. setRotation(Shape3201, 0F, 0F, 0F);
  427. Shape45487 = new ModelRenderer(this, 0, 30);
  428. Shape45487.addBox(0F, 0F, 0F, 4, 1, 4);
  429. Shape45487.setRotationPoint(-2F, 22F, -2F);
  430. Shape45487.setTextureSize(64, 64);
  431. Shape45487.mirror = true;
  432. setRotation(Shape45487, 0F, 0F, 0F);
  433. Shape3789 = new ModelRenderer(this, 0, 47);
  434. Shape3789.addBox(0F, 0F, 0F, 1, 5, 1);
  435. Shape3789.setRotationPoint(4F, 18F, 4F);
  436. Shape3789.setTextureSize(64, 64);
  437. Shape3789.mirror = true;
  438. setRotation(Shape3789, 0F, 0F, 0F);
  439. Shape4948512 = new ModelRenderer(this, 0, 30);
  440. Shape4948512.addBox(0F, 0F, 0F, 4, 1, 4);
  441. Shape4948512.setRotationPoint(-7F, 22F, -2F);
  442. Shape4948512.setTextureSize(64, 64);
  443. Shape4948512.mirror = true;
  444. setRotation(Shape4948512, 0F, 0F, 0F);
  445. Shape3544554 = new ModelRenderer(this, 0, 47);
  446. Shape3544554.addBox(0F, 0F, 0F, 1, 7, 1);
  447. Shape3544554.setRotationPoint(0F, 15F, 0F);
  448. Shape3544554.setTextureSize(64, 64);
  449. Shape3544554.mirror = true;
  450. setRotation(Shape3544554, 0F, 0F, 0F);
  451. Shape4457781 = new ModelRenderer(this, 0, 30);
  452. Shape4457781.addBox(0F, 0F, 0F, 4, 1, 4);
  453. Shape4457781.setRotationPoint(-7F, 22F, 3F);
  454. Shape4457781.setTextureSize(64, 64);
  455. Shape4457781.mirror = true;
  456. setRotation(Shape4457781, 0F, 0F, 0F);
  457. Shape344 = new ModelRenderer(this, 0, 47);
  458. Shape344.addBox(0F, 0F, 0F, 1, 5, 1);
  459. Shape344.setRotationPoint(-5F, 18F, 4F);
  460. Shape344.setTextureSize(64, 64);
  461. Shape344.mirror = true;
  462. setRotation(Shape344, 0F, 0F, 0F);
  463. Shape478787 = new ModelRenderer(this, 0, 30);
  464. Shape478787.addBox(0F, 0F, 0F, 4, 1, 4);
  465. Shape478787.setRotationPoint(3F, 22F, -7F);
  466. Shape478787.setTextureSize(64, 64);
  467. Shape478787.mirror = true;
  468. setRotation(Shape478787, 0F, 0F, 0F);
  469. Shape389587 = new ModelRenderer(this, 0, 47);
  470. Shape389587.addBox(0F, 0F, 0F, 1, 5, 1);
  471. Shape389587.setRotationPoint(4F, 19F, -5F);
  472. Shape389587.setTextureSize(64, 64);
  473. Shape389587.mirror = true;
  474. setRotation(Shape389587, 0F, 0F, 0F);
  475. Shape445665 = new ModelRenderer(this, 0, 30);
  476. Shape445665.addBox(0F, 0F, 0F, 4, 1, 4);
  477. Shape445665.setRotationPoint(3F, 22F, 3F);
  478. Shape445665.setTextureSize(64, 64);
  479. Shape445665.mirror = true;
  480. setRotation(Shape445665, 0F, 0F, 0F);
  481. }
  482.  
  483. public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
  484. super.render(entity, f, f1, f2, f3, f4, f5);
  485. setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  486. Shape1.render(f5);
  487. Shape3.render(f5);
  488. Shape44545.render(f5);
  489. Shape31412.render(f5);
  490. Shape4848.render(f5);
  491. Shape34552112.render(f5);
  492. Shape451654.render(f5);
  493. Shape3415.render(f5);
  494. Shape410210.render(f5);
  495. Shape3201.render(f5);
  496. Shape45487.render(f5);
  497. Shape3789.render(f5);
  498. Shape4948512.render(f5);
  499. Shape3544554.render(f5);
  500. Shape4457781.render(f5);
  501. Shape344.render(f5);
  502. Shape478787.render(f5);
  503. Shape389587.render(f5);
  504. Shape445665.render(f5);
  505. }
  506.  
  507. private void setRotation(ModelRenderer model, float x, float y, float z) {
  508. model.rotateAngleX = x;
  509. model.rotateAngleY = y;
  510. model.rotateAngleZ = z;
  511. }
  512.  
  513. public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
  514. super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  515. }
  516.  
  517. }
  518.  
  519. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×