public static Tuple<List<BrewEffect>, List<PotionEffect>> deSerialize(NBTTagCompound compound) { List<PotionEffect> potionEffects = PotionUtils.getEffectsFromTag(compound); List<BrewEffect> brewEffects = new ArrayList<>(); Tuple<List<BrewEffect>, List<PotionEffect>> tuple = new Tuple<>(brewEffects, potionEffects); NBTTagList list = (NBTTagList) compound.getTag(BREW_DATA); for (int i = 0, size = list.tagCount(); i < size; i++) { NBTTagCompound tag = list.getCompoundTagAt(i); IBrew brew = BrewRegistry.getRegisteredBrew(tag.getString(BREW_ID)); int duration = tag.getInteger(BREW_DURATION); int amplifier = tag.getInteger(BREW_AMPLIFIER); brewEffects.add(new BrewEffect(brew, duration, amplifier)); } return tuple; }
private void doSplash() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D); List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); if (!list.isEmpty()) { Tuple<List<BrewEffect>, List<PotionEffect>> tuple = BrewUtils.deSerialize(NBTHelper.fixNBT(getBrew())); for (EntityLivingBase entity : list) { double distance = this.getDistanceSq(entity); if (distance < 16.0D) { for (BrewEffect effect : tuple.getFirst()) { BrewStorageHandler.addEntityBrewEffect(entity, effect.copy()); } for (PotionEffect potioneffect : tuple.getSecond()) { entity.addPotionEffect(new PotionEffect(potioneffect)); } } } } }
@Override protected void readDataNBT(NBTTagCompound tag) { cooldown = tag.getInteger("cooldown"); if (tag.hasKey("ritual")) ritual = Ritual.REGISTRY.getValue(new ResourceLocation(tag.getString("ritual"))); if (tag.hasKey("player")) entityPlayer = UUID.fromString(tag.getString("player")); if (tag.hasKey("data")) ritualData = tag.getCompoundTag("data"); if (tag.hasKey("entityList")) { entityList = new ArrayList<Tuple<String, String>>(); tag.getTagList("entityList", NBT.TAG_STRING).forEach(nbts -> { String[] names = ((NBTTagString) nbts).getString().split("!"); if (names.length == 2) entityList.add(new Tuple<String, String>(names[0], names[1])); }); } }
@Override protected void writeDataNBT(NBTTagCompound tag) { tag.setInteger("cooldown", cooldown); if (ritual != null) tag.setString("ritual", ritual.getRegistryName().toString()); if (entityPlayer != null) tag.setString("player", entityPlayer.toString()); if (ritualData != null) tag.setTag("data", ritualData); NBTTagList list = new NBTTagList(); for (int i = 0; i < entityList.size(); i++) { Tuple<String, String> t = entityList.get(i); list.appendTag(new NBTTagString(t.getFirst() + "!" + t.getSecond())); } tag.setTag("entityList", list); }
@SideOnly(Side.CLIENT) @SubscribeEvent public void handleHearingSounds(PlaySoundEvent event) { EntityPlayer p = Minecraft.getMinecraft().player; if (p != null) { Tuple<SoundType, Double> result = getTypeFromSound(event.getName(), event.getSound()); if (p.getHeldItemMainhand().getItem() == this) { if (addSound(p.getHeldItemMainhand(), result.getFirst(), result.getSecond())){ PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemMainhand().getTagCompound(),true)); } } else if (p.getHeldItemOffhand().getItem() == this) { if (addSound(p.getHeldItemOffhand(), result.getFirst(), result.getSecond())){ PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemOffhand().getTagCompound(),false)); } } } }
@Override public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { if(sprite != null) { double uMin = 0F; double uMax = 1F; double vMin = 0F; double vMax = 1F; if(sprite instanceof FrameSpriteResource) { FrameSpriteResource framedSprite = ((FrameSpriteResource) sprite); Tuple<Double, Double> uv = framedSprite.getUVFrame((int) particleAngle); double uOffset = framedSprite.getU(); double u = uv.getFirst(); double vOffset = framedSprite.getV(); double v = uv.getSecond(); uMin = u; uMax = u + uOffset; vMin = v; vMax = v + vOffset; } sprite.bindManager(); renderEasy(buffer, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ, uMin, uMax, vMin, vMax); } }
@Override public WrappedBlockState deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { ResourceLocation block; List<Tuple<String, String>> properties = Lists.newArrayList(); if (json.isJsonObject()) { JsonObject jsonObject = json.getAsJsonObject(); block = context.deserialize(jsonObject.get("block"), ResourceLocation.class); if (jsonObject.has("properties")) { properties = deserializeProperties(jsonObject.get("properties")); } } else { block = context.deserialize(json, ResourceLocation.class); } return new WrappedBlockStateImpl(block, properties); }
@Override protected void actionPerformed(GuiButton button) throws IOException { if (button.id == this.okButton.id) { this.mc.displayGuiScreen(this.parent); String username = this.usernameField.getText(); String password = this.passwordField.getText(); this.futureUsernamePassword.set(new Tuple<>(username, password)); } else if (button.id == this.skipButton.id) { this.mc.displayGuiScreen(this.parent); this.futureUsernamePassword.set(new Tuple<>("", "")); } else if (button.id == this.noButton.id) { this.futureUsernamePassword.set(null); this.parent.actionPerformed(this.skipButton); // button.id == 0 } }
public boolean func_191086_a(TemplateManager p_191086_1_, int p_191086_2_, StructureEndCityPieces.CityTemplate p_191086_3_, BlockPos p_191086_4_, List<StructureComponent> p_191086_5_, Random p_191086_6_) { Rotation rotation = p_191086_3_.placeSettings.getRotation(); StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, p_191086_3_, new BlockPos(-3, 4, -3), "fat_tower_base", rotation, true)); structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(0, 4, 0), "fat_tower_middle", rotation, true)); for (int i = 0; i < 2 && p_191086_6_.nextInt(3) != 0; ++i) { structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(0, 8, 0), "fat_tower_middle", rotation, true)); for (Tuple<Rotation, BlockPos> tuple : StructureEndCityPieces.FAT_TOWER_BRIDGES) { if (p_191086_6_.nextBoolean()) { StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate1 = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, (BlockPos)tuple.getSecond(), "bridge_end", rotation.add((Rotation)tuple.getFirst()), true)); StructureEndCityPieces.func_191088_b(p_191086_1_, StructureEndCityPieces.TOWER_BRIDGE_GENERATOR, p_191086_2_ + 1, structureendcitypieces$citytemplate1, (BlockPos)null, p_191086_5_, p_191086_6_); } } } StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-2, 8, -2), "fat_tower_top", rotation, true)); return true; }
public static Tuple<Integer, ItemStack> searchForWatches(EntityLivingBase living) { if (living instanceof EntitySpy) return new Tuple<>(3, ((EntitySpy)living).loadout.getStackInSlot(3)); if (living instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) living; if (!player.getHeldItemOffhand().isEmpty() && player.getHeldItemOffhand().getItem() instanceof ItemCloak && player.getHeldItemOffhand().getTagCompound().getBoolean("Active")) // System.out.println("Found offhand"); return new Tuple<>(40,player.getHeldItemOffhand()); for (int i=0;i<player.inventory.mainInventory.size();i++) { ItemStack stack=player.inventory.mainInventory.get(i); if (!stack.isEmpty() && stack.getItem() instanceof ItemCloak && stack.getTagCompound().getBoolean("Active")) // System.out.println("Found hand"); return new Tuple<>(i,stack); } } return new Tuple<>(-1, ItemStack.EMPTY); }
public boolean generate(int p_186185_1_, StructureEndCityPieces.CityTemplate p_186185_2_, BlockPos p_186185_3_, List<StructureComponent> p_186185_4_, Random rand) { Rotation rotation = p_186185_2_.placeSettings.getRotation(); StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(p_186185_2_, new BlockPos(-3, 4, -3), "fat_tower_base", rotation, true)); structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(0, 4, 0), "fat_tower_middle", rotation, true)); for (int i = 0; i < 2 && rand.nextInt(3) != 0; ++i) { structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(0, 8, 0), "fat_tower_middle", rotation, true)); for (Tuple<Rotation, BlockPos> tuple : StructureEndCityPieces.FAT_TOWER_BRIDGES) { if (rand.nextBoolean()) { StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate1 = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, (BlockPos)tuple.getSecond(), "bridge_end", rotation.add((Rotation)tuple.getFirst()), true)); StructureEndCityPieces.recursiveChildren(StructureEndCityPieces.TOWER_BRIDGE_GENERATOR, p_186185_1_ + 1, structureendcitypieces$citytemplate1, (BlockPos)null, p_186185_4_, rand); } } } StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-2, 8, -2), "fat_tower_top", rotation, true)); return true; }
private static Tuple<Double, Boolean> step(int v1, int v2) { boolean flag = true; double d = 999.0; if (v2 > v1) { d = (double)v1 + 1.0D; } else if (v2 < v1) { d = (double)v1 + 0.0D; } else { flag = false; } return new Tuple<>(d, flag); }
private static List<Tuple<ModelRenderer, List<TexturedQuad>>> compileTexturedQuadList(List<ModelRenderer> modelRenderers) { List<Tuple<ModelRenderer, List<TexturedQuad>>> list = new ArrayList<>(); for (ModelRenderer model : modelRenderers) { List<TexturedQuad> quadList = new ArrayList<>(); for (ModelBox box : model.cubeList) { Field fieldQuads = null; for (Field field : box.getClass().getDeclaredFields()) { if (field.getType().isAssignableFrom(TexturedQuad[].class)) { fieldQuads = field; break; } } if (fieldQuads != null) { fieldQuads.setAccessible(true); try { Collections.addAll(quadList, (TexturedQuad[]) fieldQuads.get(box)); } catch (IllegalAccessException e) { e.printStackTrace(); } } } list.add(new Tuple<>(model, ImmutableList.copyOf(quadList))); } return ImmutableList.copyOf(list); }
@Override public void registerItems(InfinityMod mod, IForgeRegistry<Item> registry) { //items IProxy.super.registerItems(mod, registry); //renderers ReflectionHelper.forEachIn(mod.getModItemRegistry(), IInfinityItem.class, (IInfinityItem item) -> { if ((item instanceof Item) && item.isEnabled()) { if (item instanceof IItemWithModel) { for (Tuple<Integer, ModelResourceLocation> entry : ((IItemWithModel) item).getModelDefinitions()) { ModelLoader.setCustomModelResourceLocation((Item) item, entry.getFirst(), entry.getSecond()); } } if (item instanceof IAutoRenderedItem) { ItemRendererRegistry.getInstance().registerCustomItemRendererAuto((Item & IAutoRenderedItem) item); } else if (item instanceof ICustomRenderedItem) { ItemRendererRegistry.getInstance().registerCustomItemRenderer((Item) item, ((ICustomRenderedItem) item).getRenderer()); } } }); }
@Override public boolean registerStrategy(IAgriCrossStrategy strategy) { if (strategy.getRollChance() > 1f || strategy.getRollChance() < 0f) { throw new IndexOutOfBoundsException( "Invalid roll chance of " + strategy.getRollChance() + "!\n" + "The roll chance must be in the range 0.0 (inclusive) to 1.0 (exclusive)!" ); } else if (strategy.getRollChance() == 0) { AgriCore.getLogger("agricraft").debug("Skipping mutation strategy with zero chance!"); return false; } else if (hasStrategy(strategy)) { AgriCore.getLogger("agricraft").debug("Skipping duplicate mutation strategy!"); return false; } else { this.sigma += strategy.getRollChance(); this.strategies.add(new Tuple<>(sigma, strategy)); return true; } }
@Override public NBTBase writeNBT(Capability<INecromancyCapability> capability, INecromancyCapability instance, EnumFacing side) { //serialize stuff NBTTagCompound properties = new NBTTagCompound(); NBTTagCompound sizes = new NBTTagCompound(); for(Entry<String, Integer> e : instance.getSizeData().entrySet()) sizes.setInteger(e.getKey(), e.getValue()); properties.setTag("Sizes", sizes); NBTTagCompound data = new NBTTagCompound(); for(Tuple<String, NBTTagCompound> t : instance.getData()) data.setTag(t.getFirst(), t.getSecond()); properties.setTag("Data", data); return properties; }
@Nullable public static TileEntityWitchAltar getClosest(BlockPos pos, World world) { //Cache the returned value! Optional<Tuple<TileEntityWitchAltar, Double>> res = world.loadedTileEntityList.parallelStream() .filter(te -> te instanceof TileEntityWitchAltar) .map(te -> new Tuple<TileEntityWitchAltar, Double>((TileEntityWitchAltar) te, te.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()))) .filter(tup -> tup.getSecond() <= 256) .min((t1, t2) -> t1.getSecond().compareTo(t2.getSecond())); if (res.isPresent()) return res.get().getFirst(); return null; }
public static Tuple<SoundType, Double> getTypeFromSound(String name, ISound sound) { SoundCategory c = sound.getCategory(); if (c != null){ SoundType t = SoundType.getSoundTypeByName(c.getName()); if (t != null){ return new Tuple<>(t, t.weight); } } return new Tuple<>(SoundType.AMBIENT, 0.0); }
private void renderMirror(float age, float offset, float scale) { GlStateManager.pushMatrix(); Tuple<Double, Double> uv = SpriteLibrary.QUANTUM_MIRROR.getUVFrame((int) (age * 0.25F)); double vOffset = SpriteLibrary.QUANTUM_MIRROR.getV(); double v = uv.getSecond(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buff = tessellator.getBuffer(); GlStateManager.translate(0.5F, 0.5F, 0F); GlStateManager.scale(scale, scale, scale); GlStateManager.rotate(offset - age, 0F, 1F, 0F); GlStateManager.rotate(offset - age, 1F, 0F, 0F); GlStateManager.rotate(offset - age, 0F, 0F, 1F); GlStateManager.translate(-0.5F, -0.5F, 0F); buff.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buff.pos(0, 0, 0).tex(0, v).endVertex(); buff.pos(1, 0, 0).tex(1, v).endVertex(); buff.pos(1, 1, 0).tex(1, v + vOffset).endVertex(); buff.pos(0, 1, 0).tex(0, v + vOffset).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); }
private boolean absorb(World world, int x, int y, int z) { LinkedList<Tuple> linkedlist = Lists.newLinkedList(); ArrayList<WorldCoord> arraylist = Lists.newArrayList(); linkedlist.add(new Tuple(new WorldCoord(x, y, z), 0)); int i = 0; WorldCoord blockpos1; while (!linkedlist.isEmpty()) { Tuple tuple = linkedlist.poll(); blockpos1 = (WorldCoord) tuple.getFirst(); int j = (Integer) tuple.getSecond(); for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { WorldCoord blockpos2 = blockpos1.add(dir); if (world.getBlock(blockpos2.x, blockpos2.y, blockpos2.z).getMaterial() == Material.water) { world.setBlockToAir(blockpos2.x, blockpos2.y, blockpos2.z); arraylist.add(blockpos2); i++; if (j < 6) linkedlist.add(new Tuple(blockpos2, j + 1)); } } if (i > 64) break; } Iterator<WorldCoord> iterator = arraylist.iterator(); while (iterator.hasNext()) { blockpos1 = iterator.next(); world.notifyBlockOfNeighborChange(blockpos1.x, blockpos1.y, blockpos1.z, Blocks.air); } return i > 0; }
private List<Tuple<String, String>> deserializeProperties(JsonElement element) { if (element.isJsonObject()) { return element.getAsJsonObject().entrySet().stream() .map(e -> new Tuple<>(e.getKey(), e.getValue().getAsString())) .collect(Collectors.toList()); } else { return Arrays.stream(element.getAsString().split(",")) .map(s -> s.split("=")) .map(a -> new Tuple<>(a[0], a[1])) .collect(Collectors.toList()); } }
private SampleRenderState(IBlockState state, @Nullable NBTTagCompound matchTag, BlockArray.TileInstantiateContext context) { Tuple<IBlockState, TileEntity> tt = BlockCompatHelper.transformState(state, matchTag, context); this.state = tt.getFirst(); TileEntity te = tt.getSecond(); if(te != null) { renderData = new TileEntityRenderData(te); } else { renderData = null; } }
@Nonnull public static Tuple<IBlockState, TileEntity> transformState(IBlockState state, @Nullable NBTTagCompound matchTag, BlockArray.TileInstantiateContext context) { ResourceLocation blockRes = state.getBlock().getRegistryName(); if(ic2TileBlock.equals(blockRes) && matchTag != null) { Tuple<IBlockState, TileEntity> ret = tryRecoverTileState(state, matchTag, context); if(ret != null) { return ret; } } TileEntity te = state.getBlock().hasTileEntity(state) ? state.getBlock().createTileEntity(context.getWorld(), state) : null; if(te != null) { context.apply(te); } return new Tuple<>(state, te); }
@net.minecraftforge.fml.common.Optional.Method(modid = "ic2") private static Tuple<IBlockState, TileEntity> tryRecoverTileState(IBlockState state, @Nonnull NBTTagCompound matchTag, BlockArray.TileInstantiateContext context) { if(getTeClassIc2 == null || getITeBlockIc2 == null || getTeBlockState == null || getITEgetSupportedFacings == null || facingPropertyField == null) { return null; } ResourceLocation ic2TileBlock = new ResourceLocation("ic2", "te"); if(ic2TileBlock.equals(state.getBlock().getRegistryName())) { if(matchTag.hasKey("id")) { ResourceLocation key = new ResourceLocation(matchTag.getString("id")); if(key.getResourceDomain().equalsIgnoreCase("ic2")) { String name = key.getResourcePath(); try { Object o = getITeBlockIc2.invoke(null, name); Object oClazz = getTeClassIc2.invoke(o); if(oClazz instanceof Class) { TileEntity te = (TileEntity) ((Class) oClazz).newInstance(); if(te != null) { context.apply(te); te.readFromNBT(matchTag); IBlockState st = (IBlockState) getTeBlockState.invoke(te); EnumFacing applicable = Iterables.getFirst((Collection<EnumFacing>) getITEgetSupportedFacings.invoke(o), EnumFacing.NORTH); st = st.withProperty(facingPropertyField, applicable); return new Tuple<>(st, te); } } } catch (Throwable tr) { tr.printStackTrace(); } } } } return null; }
@Nullable public Tuple<EnumFacing, BlockArray> matchesRotation(BlockArray pattern) { EnumFacing face = EnumFacing.NORTH; do { if(pattern.matches(getWorld(), getPos(), false)) { return new Tuple<>(face, pattern); } face = face.rotateYCCW(); pattern = pattern.rotateYCCW(); } while (face != EnumFacing.NORTH); return null; }
@SuppressWarnings("unchecked") public static void addEmeraldBuyRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max) { if (min > 0 && max > 0) { EntityVillager.field_70958_bB.put(item, new Tuple(min, max)); } EntityVillager.func_146091_a(list, item, random, chance); }
@SuppressWarnings("unchecked") public static void addEmeraldSellRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max) { if (min > 0 && max > 0) { EntityVillager.field_70960_bC.put(item, new Tuple(min, max)); } EntityVillager.func_146089_b(list, item, random, chance); }
private void renderArmor(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); AbstractPonyModel modelbase; if (armorSlot == EntityEquipmentSlot.LEGS) { modelbase = pony.getArmor().modelArmor; } else { modelbase = pony.getArmor().modelArmorChestplate; } modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); modelbase.setModelAttributes(this.pony.getModel()); modelbase.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity); Tuple<ResourceLocation, Boolean> armors = getArmorTexture(entity, itemstack, armorSlot, null); prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond()); this.getRenderer().bindTexture(armors.getFirst()); if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { int color = itemarmor.getColor(itemstack); float r = (color >> 16 & 255) / 255.0F; float g = (color >> 8 & 255) / 255.0F; float b = (color & 255) / 255.0F; GlStateManager.color(r, g, b, 1); modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); this.getRenderer().bindTexture(armors.getFirst()); } GlStateManager.color(1, 1, 1, 1); modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); if (itemstack.isItemEnchanted()) { this.renderEnchantment(entity, modelbase, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); } } }
private Tuple<ResourceLocation, Boolean> getArmorTexture(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, @Nullable String type) { ItemArmor item = (ItemArmor) itemstack.getItem(); String texture = item.getArmorMaterial().getName(); String domain = "minecraft"; int idx = texture.indexOf(':'); if (idx != -1) { domain = texture.substring(0, idx); texture = texture.substring(idx + 1); } String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, slot == EntityEquipmentSlot.LEGS ? 2 : 1, type == null ? "" : String.format("_%s", type)); s1 = getArmorTexture(entity, itemstack, s1, slot, type); ResourceLocation human = getHumanResource(s1); ResourceLocation pony = getPonyResource(human); // check resource packs for either texture. for (ResourcePackRepository.Entry entry : Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries()) { if (entry.getResourcePack().resourceExists(pony)) { // ponies are more important return new Tuple<>(pony, true); } else if (entry.getResourcePack().resourceExists(human)) { // but I guess I'll take a human return new Tuple<>(human, false); } } // the default pack try { Minecraft.getMinecraft().getResourceManager().getResource(pony); return new Tuple<>(pony, true); } catch (IOException e) { return new Tuple<>(human, false); } }
@Override @SideOnly(Side.CLIENT) public List<Tuple<Integer, ModelResourceLocation>> getModelDefinitions() { List<Tuple<Integer, ModelResourceLocation>> list = new ArrayList<>(); list.add(new Tuple<>(0, new ModelResourceLocation(Reference.MOD_ID.toLowerCase() + ":" + internalName, "inventory"))); return list; }
@Override @SideOnly(Side.CLIENT) public List<Tuple<Integer, ModelResourceLocation>> getModelDefinitions() { List<Tuple<Integer, ModelResourceLocation>> list = new ArrayList<>(); list.add(new Tuple<>(0, new ModelResourceLocation(Reference.MOD_ID.toLowerCase() + ":maneuver_gear", "inventory"))); return list; }
@Override public void readFromNBT(NBTTagCompound compound) { this.world = READING_WORLD.get(); if (LOAD.get()) { this.partitions.clear(); this.blockSystems.clear(); BlockSystem.nextID = compound.getInteger("NextID"); try { NBTTagList blockSystemsList = compound.getTagList("BlockSystems", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < blockSystemsList.tagCount(); i++) { NBTTagCompound tag = blockSystemsList.getCompoundTagAt(i); BlockSystem system = BlockSystems.PROXY.createBlockSystem(this.world, BlockSystem.nextID++); CURRENTLY_LOADING.set(system); system.deserialize(tag); BlockSystems.PROXY.getBlockSystemHandler(this.world).loadBlockSystem(system); this.addBlockSystem(system); CURRENTLY_LOADING.set(null); } } finally { List<Tuple<BlockPos, BlockSystem>> queuedPartitions = QUEUED_PARTITIONS.remove(this.world); if (queuedPartitions != null) { for (Tuple<BlockPos, BlockSystem> partition : queuedPartitions) { this.addPartition(partition.getFirst(), partition.getSecond()); } } } } }
/** * @return a list with metadata values and ModelResourceLocations corresponding with it. */ @SideOnly(Side.CLIENT) default List<Tuple<Integer, ModelResourceLocation>> getModelDefinitions() { return ImmutableList.of( new Tuple<>(0, new ModelResourceLocation(this.getRegistryName() + "")) ); }
@Nullable public static RayTraceResult getTargetBlock(Entity entity, double distance) { Optional<Tuple<Vec3d, Vec3d>> eyesAndTrace = getEyesAndTraceVectors(entity, distance); if(!eyesAndTrace.isPresent()) { return null; } return entity.getEntityWorld().rayTraceBlocks(eyesAndTrace.get().getFirst(), eyesAndTrace.get().getSecond(), false, false, true); }
@Nullable public static RayTraceResult getTargetEntityOrBlock(Entity entity, double distance) { Optional<Tuple<Vec3d, Vec3d>> eyesAndTrace = getEyesAndTraceVectors(entity, distance); if(!eyesAndTrace.isPresent()) { return null; } return rayTraceBlocksForEntity(entity, entity.getEntityWorld(), eyesAndTrace.get().getFirst(), eyesAndTrace.get().getSecond(), false, false, true); }
@Nullable public static RayTraceResult getTargetEntityOrBlock(Entity entity, double distance, Class<? extends Entity> entityClass) { Optional<Tuple<Vec3d, Vec3d>> eyesAndTrace = getEyesAndTraceVectors(entity, distance); if(!eyesAndTrace.isPresent()) { return null; } return rayTraceBlocksForEntity(entity, entity.getEntityWorld(), eyesAndTrace.get().getFirst(), eyesAndTrace.get().getSecond(), false, false, true, entityClass); }
@Nullable public static RayTraceResult getTargetEntityOrBlock(Entity entity, double distance, Predicate<? super Entity> filter) { Optional<Tuple<Vec3d, Vec3d>> eyesAndTrace = getEyesAndTraceVectors(entity, distance); if(!eyesAndTrace.isPresent()) { return null; } return rayTraceBlocksForEntity(entity, entity.getEntityWorld(), eyesAndTrace.get().getFirst(), eyesAndTrace.get().getSecond(), false, false, true, filter); }
private static Optional<Tuple<Vec3d, Vec3d>> getEyesAndTraceVectors(Entity entity, double distance) { Vec3d eyes = new Vec3d(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ); Vec3d look = entity.getLookVec(); if(look == null) { return Optional.empty(); } Vec3d trace = eyes.addVector(look.x * distance, look.y * distance, look.z * distance); return Optional.of(new Tuple<>(eyes, trace)); }
@Override @SideOnly(Side.CLIENT) public List<Tuple<Integer, ModelResourceLocation>> getModelDefinitions() { List<Tuple<Integer, ModelResourceLocation>> list = new ArrayList<>(); list.add(new Tuple<>(0, new ModelResourceLocation(Reference.MOD_ID.toLowerCase()+ ":" + getInternalName(), "inventory"))); return list; }
@Override public Tuple<IInventory, Integer> getInventoryAndSlotForGlobalSlot(int slot) { if(slot >= this.getSizeInventory()) { return null; } for (IInventory inventory : this.inventories) { int size = inventory.getSizeInventory(); if (slot >= size) { slot = slot - size; } else { return new Tuple<>(inventory, slot); } } return null; }