public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) { if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) { return false; } final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class); final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class); modifiers.put(DamageModifier.BASE, damage); functions.put(DamageModifier.BASE, ZERO); final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions); if (event == null) { return false; } return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal }
@SideOnly(Side.CLIENT) public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) { if (entityIn == null && !stack.isOnItemFrame()) return 0.0F; else { boolean flag = entityIn != null; Entity entity = (Entity)(flag ? entityIn : stack.getItemFrame()); if (worldIn == null) worldIn = entity.world; double d0; if (worldIn.provider.isSurfaceWorld()) { double d1 = flag ? (double)entity.rotationYaw : this.getFrameRotation((EntityItemFrame)entity); d1 = MathHelper.positiveModulo(d1 / 360.0D, 1.0D); double d2 = this.getSpawnToAngle(worldIn, entity) / (Math.PI * 2D); d0 = 0.5D - (d1 - 0.25D - d2); } else d0 = Math.random(); if (flag) d0 = this.wobble(worldIn, d0); return MathHelper.positiveModulo((float)d0, 1.0F); } }
/** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(EntityItemFrame par1EntityItemFrame, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); double var10 = par1EntityItemFrame.posX - par2 - 0.5D; double var12 = par1EntityItemFrame.posY - par4 - 0.5D; double var14 = par1EntityItemFrame.posZ - par6 - 0.5D; int var16 = par1EntityItemFrame.field_146063_b + Direction.offsetX[par1EntityItemFrame.hangingDirection]; int var17 = par1EntityItemFrame.field_146064_c; int var18 = par1EntityItemFrame.field_146062_d + Direction.offsetZ[par1EntityItemFrame.hangingDirection]; GL11.glTranslated((double)var16 - var10, (double)var17 - var12, (double)var18 - var14); if (par1EntityItemFrame.getDisplayedItem() != null && par1EntityItemFrame.getDisplayedItem().getItem() == Items.filled_map) { this.func_147915_b(par1EntityItemFrame); } else { this.renderFrameItemAsBlock(par1EntityItemFrame); } this.func_82402_b(par1EntityItemFrame); GL11.glPopMatrix(); this.func_147914_a(par1EntityItemFrame, par2 + (double)((float)Direction.offsetX[par1EntityItemFrame.hangingDirection] * 0.3F), par4 - 0.25D, par6 + (double)((float)Direction.offsetZ[par1EntityItemFrame.hangingDirection] * 0.3F)); }
public void doRender(EntityItemFrame p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { GL11.glPushMatrix(); double d3 = p_76986_1_.posX - p_76986_2_ - 0.5D; double d4 = p_76986_1_.posY - p_76986_4_ - 0.5D; double d5 = p_76986_1_.posZ - p_76986_6_ - 0.5D; int i = p_76986_1_.field_146063_b + Direction.offsetX[p_76986_1_.hangingDirection]; int j = p_76986_1_.field_146064_c; int k = p_76986_1_.field_146062_d + Direction.offsetZ[p_76986_1_.hangingDirection]; GL11.glTranslated((double)i - d3, (double)j - d4, (double)k - d5); if (p_76986_1_.getDisplayedItem() != null && p_76986_1_.getDisplayedItem().getItem() == Items.filled_map) { this.func_147915_b(p_76986_1_); } else { this.renderFrameItemAsBlock(p_76986_1_); } this.func_82402_b(p_76986_1_); GL11.glPopMatrix(); this.func_147914_a(p_76986_1_, p_76986_2_ + (double)((float)Direction.offsetX[p_76986_1_.hangingDirection] * 0.3F), p_76986_4_ - 0.25D, p_76986_6_ + (double)((float)Direction.offsetZ[p_76986_1_.hangingDirection] * 0.3F)); }
@Override public void doRender(EntityItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks) { ItemStack frameItemStack = ItemStack.EMPTY; if (!CheckVisibleState(entity)) { frameItemStack = entity.getDisplayedItem(); entity.setDisplayedItem(ItemStack.EMPTY); } if ((!SkipSignCore.ModSetting.HideBoard.Bool()) || (SkipSignCore.ModSetting.HideBoard.Bool() && CheckVisibleState(entity))) { super.doRender(entity, x, y, z, entityYaw, partialTicks); } if (!frameItemStack.isEmpty()) { entity.setDisplayedItem(frameItemStack); } }
public boolean CheckVisibleState(EntityItemFrame entityItemFrame) { if (SkipSignCore.ModSetting.FrameVisible.Int() == 1) return true; if (SkipSignCore.ModSetting.FrameVisible.Int() == 2) return false; if (Keyboard.isKeyDown(SkipSignCore.ModSetting.Zoom_Key.Int())) return true; if (SkipSignHelper.IsInRangeToRenderDist( SkipSignHelper.GetDistancePlayerToEntity(entityItemFrame), SkipSignCore.ModSetting.FrameRange.Int())) return true; return false; }
/** * Gets the range an entity should be 'tracked' by players and visible in * the client. * * @param entity * @param defaultRange Default range defined by Mojang * @return */ public static int getEntityTrackingRange(Entity entity, int defaultRange) { SpigotWorldConfig config = entity.worldObj.getSpigotConfig(); // Cauldron int range = defaultRange; if ( entity instanceof EntityPlayerMP ) { range = config.playerTrackingRange; } else if ( entity.defaultActivationState || entity instanceof EntityGhast ) { range = defaultRange; } else if ( entity.activationType == 1 ) { range = config.monsterTrackingRange; } else if ( entity.activationType == 2 ) { range = config.animalTrackingRange; } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb ) { range = config.miscTrackingRange; } // Cauldron start - allow for 0 to disable tracking ranges if (range == 0) { return defaultRange; } // Cauldron end return Math.min( config.maxTrackingRange, range ); }
/** * Find all chests that have an item frame attached to them with an meecreep cube in them */ private List<BlockPos> findMeeCreepChests(AxisAlignedBB box) { List<EntityItemFrame> frames = entity.getEntityWorld().getEntitiesWithinAABB(EntityItemFrame.class, box, input -> { if (!input.getDisplayedItem().isEmpty() && input.getDisplayedItem().getItem() instanceof CreepCubeItem) { BlockPos position = input.getHangingPosition().offset(input.facingDirection.getOpposite()); if (InventoryTools.isInventory(entity.getEntityWorld(), position)) { return true; } } return false; }); return frames.stream().map(entityItemFrame -> entityItemFrame.getHangingPosition().offset(entityItemFrame.facingDirection.getOpposite())).collect(Collectors.toList()); }
private int getEntityColor(Entity entity) { if(entity instanceof EntityMinecartChest) return Utils.Colors.ORANGE; else if(entity instanceof EntityItemFrame && ((EntityItemFrame) entity).getDisplayedItem().getItem() instanceof ItemShulkerBox) return Utils.Colors.YELLOW; else return -1; }
protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state) { int i = super.calculateInputStrength(worldIn, pos, state); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); BlockPos blockpos = pos.offset(enumfacing); Block block = worldIn.getBlockState(blockpos).getBlock(); if (block.hasComparatorInputOverride()) { i = block.getComparatorInputOverride(worldIn, blockpos); } else if (i < 15 && block.isNormalCube()) { blockpos = blockpos.offset(enumfacing); block = worldIn.getBlockState(blockpos).getBlock(); if (block.hasComparatorInputOverride()) { i = block.getComparatorInputOverride(worldIn, blockpos); } else if (block.getMaterial() == Material.air) { EntityItemFrame entityitemframe = this.findItemFrame(worldIn, enumfacing, blockpos); if (entityitemframe != null) { i = entityitemframe.func_174866_q(); } } } return i; }
private EntityItemFrame findItemFrame(World worldIn, final EnumFacing facing, BlockPos pos) { List<EntityItemFrame> list = worldIn.<EntityItemFrame>getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1)), new Predicate<Entity>() { public boolean apply(Entity p_apply_1_) { return p_apply_1_ != null && p_apply_1_.getHorizontalFacing() == facing; } }); return list.size() == 1 ? (EntityItemFrame)list.get(0) : null; }
/** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity>) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doe */ public void doRender(EntityItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); BlockPos blockpos = entity.getHangingPosition(); double d0 = (double)blockpos.getX() - entity.posX + x; double d1 = (double)blockpos.getY() - entity.posY + y; double d2 = (double)blockpos.getZ() - entity.posZ + z; GlStateManager.translate(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D); GlStateManager.rotate(180.0F - entity.rotationYaw, 0.0F, 1.0F, 0.0F); this.renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture); BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher(); ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager(); IBakedModel ibakedmodel; if (entity.getDisplayedItem() != null && entity.getDisplayedItem().getItem() == Items.filled_map) { ibakedmodel = modelmanager.getModel(this.mapModel); } else { ibakedmodel = modelmanager.getModel(this.itemFrameModel); } GlStateManager.pushMatrix(); GlStateManager.translate(-0.5F, -0.5F, -0.5F); blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); GlStateManager.translate(0.0F, 0.0F, 0.4375F); this.renderItem(entity); GlStateManager.popMatrix(); this.renderName(entity, x + (double)((float)entity.facingDirection.getFrontOffsetX() * 0.3F), y - 0.25D, z + (double)((float)entity.facingDirection.getFrontOffsetZ() * 0.3F)); }
protected void handleDataMarker(String p_186175_1_, BlockPos p_186175_2_, World p_186175_3_, Random p_186175_4_, StructureBoundingBox p_186175_5_) { if (p_186175_1_.startsWith("Chest")) { BlockPos blockpos = p_186175_2_.down(); if (p_186175_5_.isVecInside(blockpos)) { TileEntity tileentity = p_186175_3_.getTileEntity(blockpos); if (tileentity instanceof TileEntityChest) { ((TileEntityChest)tileentity).setLootTable(LootTableList.CHESTS_END_CITY_TREASURE, p_186175_4_.nextLong()); } } } else if (p_186175_1_.startsWith("Sentry")) { EntityShulker entityshulker = new EntityShulker(p_186175_3_); entityshulker.setPosition((double)p_186175_2_.getX() + 0.5D, (double)p_186175_2_.getY() + 0.5D, (double)p_186175_2_.getZ() + 0.5D); entityshulker.setAttachmentPos(p_186175_2_); p_186175_3_.spawnEntityInWorld(entityshulker); } else if (p_186175_1_.startsWith("Elytra")) { EntityItemFrame entityitemframe = new EntityItemFrame(p_186175_3_, p_186175_2_, this.rotation.rotate(EnumFacing.SOUTH)); entityitemframe.setDisplayedItem(new ItemStack(Items.ELYTRA)); p_186175_3_.spawnEntityInWorld(entityitemframe); } }
@Nullable /** * Return the item frame this stack is on. Returns null if not on an item frame. */ public EntityItemFrame getItemFrame() { return this.field_190928_g ? null : this.itemFrame; }
protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state) { int i = super.calculateInputStrength(worldIn, pos, state); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); BlockPos blockpos = pos.offset(enumfacing); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.hasComparatorInputOverride()) { i = iblockstate.getComparatorInputOverride(worldIn, blockpos); } else if (i < 15 && iblockstate.isNormalCube()) { blockpos = blockpos.offset(enumfacing); iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.hasComparatorInputOverride()) { i = iblockstate.getComparatorInputOverride(worldIn, blockpos); } else if (iblockstate.getMaterial() == Material.AIR) { EntityItemFrame entityitemframe = this.findItemFrame(worldIn, enumfacing, blockpos); if (entityitemframe != null) { i = entityitemframe.getAnalogOutput(); } } } return i; }
@Nullable private EntityItemFrame findItemFrame(World worldIn, final EnumFacing facing, BlockPos pos) { List<EntityItemFrame> list = worldIn.<EntityItemFrame>getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1)), new Predicate<Entity>() { public boolean apply(@Nullable Entity p_apply_1_) { return p_apply_1_ != null && p_apply_1_.getHorizontalFacing() == facing; } }); return list.size() == 1 ? (EntityItemFrame)list.get(0) : null; }
@Nullable /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityItemFrame entity) { return null; }
protected void renderName(EntityItemFrame entity, double x, double y, double z) { if (Minecraft.isGuiEnabled() && !entity.getDisplayedItem().func_190926_b() && entity.getDisplayedItem().hasDisplayName() && this.renderManager.pointedEntity == entity) { double d0 = entity.getDistanceSqToEntity(this.renderManager.renderViewEntity); float f = entity.isSneaking() ? 32.0F : 64.0F; if (d0 < (double)(f * f)) { String s = entity.getDisplayedItem().getDisplayName(); this.renderLivingLabel(entity, s, x, y, z, 64); } } }
protected void renderName(EntityItemFrame entity, double x, double y, double z) { if (Minecraft.isGuiEnabled() && entity.getDisplayedItem() != null && entity.getDisplayedItem().hasDisplayName() && this.renderManager.pointedEntity == entity) { double d0 = entity.getDistanceSqToEntity(this.renderManager.renderViewEntity); float f = entity.isSneaking() ? 32.0F : 64.0F; if (d0 < (double)(f * f)) { String s = entity.getDisplayedItem().getDisplayName(); this.renderLivingLabel(entity, s, x, y, z, 64); } } }
@Override public void doRender(EntityItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks) { EntityArtifactFrame frame = (EntityArtifactFrame) entity; GlStateManager.pushMatrix(); BlockPos blockpos = entity.getHangingPosition(); double d0 = (double)blockpos.getX() - entity.posX + x; double d1 = (double)blockpos.getY() - entity.posY + y; double d2 = (double)blockpos.getZ() - entity.posZ + z; GlStateManager.translate(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D); GlStateManager.rotate(180.0F - entity.rotationYaw, 0.0F, 1.0F, 0.0F); this.renderManager.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.pushMatrix(); GlStateManager.translate(-0.5F, -0.5F, -0.5F); if(renderOutlines) { GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(getTeamColor(entity)); } renderModel(frame); if(renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.popMatrix(); GlStateManager.translate(0.0F, 0.0F, 0.4375F); this.renderItem(frame); GlStateManager.popMatrix(); this.renderName(entity, x + (double)((float)entity.facingDirection.getFrontOffsetX() * 0.3F), y - 0.25D, z + (double)((float)entity.facingDirection.getFrontOffsetZ() * 0.3F)); }