/** * Renders the desired {@code T} type Entity. */ public void doRender(EntityShulkerBullet entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); float f = this.rotLerp(entity.prevRotationYaw, entity.rotationYaw, partialTicks); float f1 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks; float f2 = (float)entity.ticksExisted + partialTicks; GlStateManager.translate((float)x, (float)y + 0.15F, (float)z); GlStateManager.rotate(MathHelper.sin(f2 * 0.1F) * 180.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(MathHelper.cos(f2 * 0.1F) * 180.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(MathHelper.sin(f2 * 0.15F) * 360.0F, 0.0F, 0.0F, 1.0F); float f3 = 0.03125F; GlStateManager.enableRescaleNormal(); GlStateManager.scale(-1.0F, -1.0F, 1.0F); this.bindEntityTexture(entity); this.model.render(entity, 0.0F, 0.0F, 0.0F, f, f1, 0.03125F); GlStateManager.enableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F); GlStateManager.scale(1.5F, 1.5F, 1.5F); this.model.render(entity, 0.0F, 0.0F, 0.0F, f, f1, 0.03125F); GlStateManager.disableBlend(); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); }
public void updateTask() { if (EntityShulker.this.world.getDifficulty() != EnumDifficulty.PEACEFUL) { --this.attackTime; EntityLivingBase entitylivingbase = EntityShulker.this.getAttackTarget(); EntityShulker.this.getLookHelper().setLookPositionWithEntity(entitylivingbase, 180.0F, 180.0F); double d0 = EntityShulker.this.getDistanceSqToEntity(entitylivingbase); if (d0 < 400.0D) { if (this.attackTime <= 0) { this.attackTime = 20 + EntityShulker.this.rand.nextInt(10) * 20 / 2; EntityShulkerBullet entityshulkerbullet = new EntityShulkerBullet(EntityShulker.this.world, EntityShulker.this, entitylivingbase, EntityShulker.this.getAttachmentFacing().getAxis()); EntityShulker.this.world.spawnEntityInWorld(entityshulkerbullet); EntityShulker.this.playSound(SoundEvents.ENTITY_SHULKER_SHOOT, 2.0F, (EntityShulker.this.rand.nextFloat() - EntityShulker.this.rand.nextFloat()) * 0.2F + 1.0F); } } else { EntityShulker.this.setAttackTarget((EntityLivingBase)null); } super.updateTask(); } }
/** * Updates the task */ public void updateTask() { if (EntityShulker.this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL) { --this.attackTime; EntityLivingBase entitylivingbase = EntityShulker.this.getAttackTarget(); EntityShulker.this.getLookHelper().setLookPositionWithEntity(entitylivingbase, 180.0F, 180.0F); double d0 = EntityShulker.this.getDistanceSqToEntity(entitylivingbase); if (d0 < 400.0D) { if (this.attackTime <= 0) { this.attackTime = 20 + EntityShulker.this.rand.nextInt(10) * 20 / 2; EntityShulkerBullet entityshulkerbullet = new EntityShulkerBullet(EntityShulker.this.worldObj, EntityShulker.this, entitylivingbase, EntityShulker.this.getAttachmentFacing().getAxis()); EntityShulker.this.worldObj.spawnEntityInWorld(entityshulkerbullet); EntityShulker.this.playSound(SoundEvents.ENTITY_SHULKER_SHOOT, 2.0F, (EntityShulker.this.rand.nextFloat() - EntityShulker.this.rand.nextFloat()) * 0.2F + 1.0F); } } else { EntityShulker.this.setAttackTarget((EntityLivingBase)null); } super.updateTask(); } }
@Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { TileEntity tile = world.getTileEntity(pos); if(tile !=null && tile instanceof TileJar){ TileJar jar = (TileJar)tile; if(jar.isShulkerLamp() && !player.capabilities.isCreativeMode){ if(!world.isRemote){ EntityShulkerBullet bullet = new EntityShulkerBullet(world); bullet.setLocationAndAngles(pos.getX() + 0.5, pos.getY() + 1 + 0.5, pos.getZ() + 0.5, bullet.rotationYaw, bullet.rotationPitch); ReflectionHelper.setPrivateValue(EntityShulkerBullet.class, bullet, player, 1); ReflectionHelper.setPrivateValue(EntityShulkerBullet.class, bullet, EnumFacing.UP, 2); try { Method method = EntityShulkerBullet.class.getDeclaredMethod("selectNextMoveDirection", EnumFacing.Axis.class); if(method == null){ method = EntityShulkerBullet.class.getDeclaredMethod("func_184569_a", EnumFacing.Axis.class); } if(method !=null){ method.setAccessible(true); method.invoke(bullet, EnumFacing.Axis.Y); } else { throw new Exception("Unable to find the selectNextMoveDirection method in "+EntityShulkerBullet.class.getCanonicalName()); } } catch (Exception e) { e.printStackTrace(); } world.spawnEntity(bullet); } jar.setShulkerLamp(false); } } if (willHarvest) { return true; } return super.removedByPlayer(state, world, pos, player, willHarvest); }
@Override public void execute(EntityLivingBase target, @Nullable AbstractMorph morph) { World world = target.worldObj; if (world.isRemote) { return; } if (target instanceof EntityPlayer && ((EntityPlayer) target).getCooledAttackStrength(0.0F) < 1) { return; } Entity toShoot = EntityUtils.getTargetEntity(target, 32); if (toShoot != null) { target.playSound(SoundEvents.ENTITY_SHULKER_SHOOT, 2.0F, (target.getRNG().nextFloat() - target.getRNG().nextFloat()) * 0.2F + 1.0F); EntityShulkerBullet fireball = new EntityShulkerBullet(world, target, toShoot, Axis.Z); fireball.posX = target.posX; fireball.posZ = target.posZ; world.spawnEntityInWorld(fireball); } if (target instanceof EntityPlayer) { ((EntityPlayer) target).resetCooldown(); } }
public ModelAdapterShulkerBullet() { super(EntityShulkerBullet.class, "shulker_bullet", 0.0F); }
/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityShulkerBullet entity) { return SHULKER_SPARK_TEXTURE; }
public RenderManager(TextureManager renderEngineIn, RenderItem itemRendererIn) { this.renderEngine = renderEngineIn; this.entityRenderMap.put(EntityCaveSpider.class, new RenderCaveSpider(this)); this.entityRenderMap.put(EntitySpider.class, new RenderSpider(this)); this.entityRenderMap.put(EntityPig.class, new RenderPig(this, new ModelPig(), 0.7F)); this.entityRenderMap.put(EntitySheep.class, new RenderSheep(this, new ModelSheep2(), 0.7F)); this.entityRenderMap.put(EntityCow.class, new RenderCow(this, new ModelCow(), 0.7F)); this.entityRenderMap.put(EntityMooshroom.class, new RenderMooshroom(this, new ModelCow(), 0.7F)); this.entityRenderMap.put(EntityWolf.class, new RenderWolf(this, new ModelWolf(), 0.5F)); this.entityRenderMap.put(EntityChicken.class, new RenderChicken(this, new ModelChicken(), 0.3F)); this.entityRenderMap.put(EntityOcelot.class, new RenderOcelot(this, new ModelOcelot(), 0.4F)); this.entityRenderMap.put(EntityRabbit.class, new RenderRabbit(this, new ModelRabbit(), 0.3F)); this.entityRenderMap.put(EntitySilverfish.class, new RenderSilverfish(this)); this.entityRenderMap.put(EntityEndermite.class, new RenderEndermite(this)); this.entityRenderMap.put(EntityCreeper.class, new RenderCreeper(this)); this.entityRenderMap.put(EntityEnderman.class, new RenderEnderman(this)); this.entityRenderMap.put(EntitySnowman.class, new RenderSnowMan(this)); this.entityRenderMap.put(EntitySkeleton.class, new RenderSkeleton(this)); this.entityRenderMap.put(EntityWitch.class, new RenderWitch(this)); this.entityRenderMap.put(EntityBlaze.class, new RenderBlaze(this)); this.entityRenderMap.put(EntityPigZombie.class, new RenderPigZombie(this)); this.entityRenderMap.put(EntityZombie.class, new RenderZombie(this)); this.entityRenderMap.put(EntitySlime.class, new RenderSlime(this, new ModelSlime(16), 0.25F)); this.entityRenderMap.put(EntityMagmaCube.class, new RenderMagmaCube(this)); this.entityRenderMap.put(EntityGiantZombie.class, new RenderGiantZombie(this, new ModelZombie(), 0.5F, 6.0F)); this.entityRenderMap.put(EntityGhast.class, new RenderGhast(this)); this.entityRenderMap.put(EntitySquid.class, new RenderSquid(this, new ModelSquid(), 0.7F)); this.entityRenderMap.put(EntityVillager.class, new RenderVillager(this)); this.entityRenderMap.put(EntityIronGolem.class, new RenderIronGolem(this)); this.entityRenderMap.put(EntityBat.class, new RenderBat(this)); this.entityRenderMap.put(EntityGuardian.class, new RenderGuardian(this)); this.entityRenderMap.put(EntityShulker.class, new RenderShulker(this, new ModelShulker())); this.entityRenderMap.put(EntityPolarBear.class, new RenderPolarBear(this, new ModelPolarBear(), 0.7F)); this.entityRenderMap.put(EntityDragon.class, new RenderDragon(this)); this.entityRenderMap.put(EntityEnderCrystal.class, new RenderEnderCrystal(this)); this.entityRenderMap.put(EntityWither.class, new RenderWither(this)); this.entityRenderMap.put(Entity.class, new RenderEntity(this)); this.entityRenderMap.put(EntityPainting.class, new RenderPainting(this)); this.entityRenderMap.put(EntityItemFrame.class, new RenderItemFrame(this, itemRendererIn)); this.entityRenderMap.put(EntityLeashKnot.class, new RenderLeashKnot(this)); this.entityRenderMap.put(EntityTippedArrow.class, new RenderTippedArrow(this)); this.entityRenderMap.put(EntitySpectralArrow.class, new RenderSpectralArrow(this)); this.entityRenderMap.put(EntitySnowball.class, new RenderSnowball(this, Items.SNOWBALL, itemRendererIn)); this.entityRenderMap.put(EntityEnderPearl.class, new RenderSnowball(this, Items.ENDER_PEARL, itemRendererIn)); this.entityRenderMap.put(EntityEnderEye.class, new RenderSnowball(this, Items.ENDER_EYE, itemRendererIn)); this.entityRenderMap.put(EntityEgg.class, new RenderSnowball(this, Items.EGG, itemRendererIn)); this.entityRenderMap.put(EntityPotion.class, new RenderPotion(this, itemRendererIn)); this.entityRenderMap.put(EntityExpBottle.class, new RenderSnowball(this, Items.EXPERIENCE_BOTTLE, itemRendererIn)); this.entityRenderMap.put(EntityFireworkRocket.class, new RenderSnowball(this, Items.FIREWORKS, itemRendererIn)); this.entityRenderMap.put(EntityLargeFireball.class, new RenderFireball(this, 2.0F)); this.entityRenderMap.put(EntitySmallFireball.class, new RenderFireball(this, 0.5F)); this.entityRenderMap.put(EntityDragonFireball.class, new RenderDragonFireball(this)); this.entityRenderMap.put(EntityWitherSkull.class, new RenderWitherSkull(this)); this.entityRenderMap.put(EntityShulkerBullet.class, new RenderShulkerBullet(this)); this.entityRenderMap.put(EntityItem.class, new RenderEntityItem(this, itemRendererIn)); this.entityRenderMap.put(EntityXPOrb.class, new RenderXPOrb(this)); this.entityRenderMap.put(EntityTNTPrimed.class, new RenderTNTPrimed(this)); this.entityRenderMap.put(EntityFallingBlock.class, new RenderFallingBlock(this)); this.entityRenderMap.put(EntityArmorStand.class, new RenderArmorStand(this)); this.entityRenderMap.put(EntityMinecartTNT.class, new RenderTntMinecart(this)); this.entityRenderMap.put(EntityMinecartMobSpawner.class, new RenderMinecartMobSpawner(this)); this.entityRenderMap.put(EntityMinecart.class, new RenderMinecart(this)); this.entityRenderMap.put(EntityBoat.class, new RenderBoat(this)); this.entityRenderMap.put(EntityFishHook.class, new RenderFish(this)); this.entityRenderMap.put(EntityAreaEffectCloud.class, new RenderAreaEffectCloud(this)); this.entityRenderMap.put(EntityHorse.class, new RenderHorse(this, new ModelHorse(), 0.75F)); this.entityRenderMap.put(EntityLightningBolt.class, new RenderLightningBolt(this)); this.playerRenderer = new RenderPlayer(this); this.skinMap.put("default", this.playerRenderer); this.skinMap.put("slim", new RenderPlayer(this, true)); net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(this, this.entityRenderMap); }
@SubscribeEvent public void onEntityLivingInteract(EntityInteract event) { if(event.getTarget() == null)return; EntityPlayer player = event.getEntityPlayer(); ItemStack held = event.getItemStack(); Entity entity = event.getTarget(); if(entity instanceof AbstractHorse){ AbstractHorse horse = (AbstractHorse)entity; if(HorseAccessories.handleHorseInteract(player, held, event.getHand(), horse)){ event.setCanceled(true); } } if(entity instanceof EntityWolf){ if(WolfAccessories.handleWolfInteract(player, held, event.getHand(), (EntityWolf)entity)){ event.setCanceled(true); } } if(entity instanceof EntityPolarBear){ EntityPolarBear bear = (EntityPolarBear)entity; if(ItemStackTools.isValid(held)){ if(held.getItem() == ModItems.miscFood && held.getMetadata() == FoodType.WHITE_FISH_RAW.getMetadata()){ if (!player.capabilities.isCreativeMode) { held.shrink(1); } if (!player.getEntityWorld().isRemote){ if (EntityUtil.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(bear, player)) { EntityTamedPolarBear.convertToTamed(player.getEntityWorld(), bear, player); } } event.setCanceled(true); } } } if(entity instanceof EntityShulkerBullet){ if(ItemStackTools.isValid(held)){ if(held.getItem() == Item.getItemFromBlock(ModBlocks.jar)){ NBTTagCompound nbt = new NBTTagCompound(); if(held.hasTagCompound() && held.getTagCompound().hasKey(BlockJar.TILE_NBT_STACK)){ nbt = ItemNBTHelper.getCompound(held).getCompoundTag(BlockJar.TILE_NBT_STACK); } if((!nbt.hasKey("IsShulker") || !nbt.getBoolean("IsShulker")) && (!nbt.hasKey("Count") || nbt.getInteger("Count") <=0)){ nbt.setBoolean("IsShulker", true); if(ItemStackTools.getStackSize(held) == 1){ ItemNBTHelper.getCompound(held).setTag(BlockJar.TILE_NBT_STACK, nbt); } else { ItemStack newStack = ItemUtil.copy(held, 1); ItemNBTHelper.getCompound(newStack).setTag(BlockJar.TILE_NBT_STACK, nbt); player.setHeldItem(event.getHand(), ItemUtil.consumeItem(held)); if(!player.inventory.addItemStackToInventory(newStack)){ ItemUtil.dropFromPlayer(player, newStack, false); } } entity.setDead(); } } } } }