@Override public IFlexibleBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { IFlexibleBakedModel bakedBase = null; if (base != null) bakedBase = base.bake(state, format, bakedTextureGetter); ImmutableMap.Builder<String, IFlexibleBakedModel> mapBuilder = ImmutableMap.builder(); for (Entry<String, Pair<IModel, IModelState>> entry : parts.entrySet()) { Pair<IModel, IModelState> pair = entry.getValue(); mapBuilder.put( entry.getKey(), pair.getLeft().bake(pair.getRight(), format, bakedTextureGetter)); } if (bakedBase == null && parts.isEmpty()) { FMLLog.log( Level.ERROR, "MultiModel %s is empty (no base model or parts were provided/resolved)", location); IModel missing = ModelLoaderRegistry.getMissingModel(); return missing.bake(missing.getDefaultState(), format, bakedTextureGetter); } return new Baked(location, true, bakedBase, mapBuilder.build()); }
public static void rebakeMap() { // System.out.println("Baking OreDictionary:"); stackToId.clear(); for (int id = 0; id < idToStack.size(); id++) { List<ItemStack> ores = idToStack.get(id); if (ores == null) continue; for (ItemStack ore : ores) { // HACK: use the registry name's ID. It is unique and it knows about substitutions ResourceLocation name = ore.getItem().delegate.name(); int hash; if (name == null) { FMLLog.log( Level.DEBUG, "Defaulting unregistered ore dictionary entry for ore dictionary %s: type %s to -1", getOreName(id), ore.getItem().getClass()); hash = -1; } else { hash = GameData.getItemRegistry().getId(name); } if (ore.getItemDamage() != WILDCARD_VALUE) { hash |= ((ore.getItemDamage() + 1) << 16); // +1 so meta 0 is significant } List<Integer> ids = stackToId.get(hash); if (ids == null) { ids = Lists.newArrayList(); stackToId.put(hash, ids); } ids.add(id); // System.out.println(id + " " + getOreName(id) + " " + Integer.toHexString(hash) + " " + // ore); } } }
/** * Gets all the integer ID for the ores that the specified item stack is registered to. If the * item stack is not linked to any ore, this will return an empty array and no new entry will be * created. * * @param stack The item stack of the ore. * @return An array of ids that this ore is registered as. */ public static int[] getOreIDs(ItemStack stack) { if (stack == null || stack.getItem() == null) throw new IllegalArgumentException("Stack can not be null!"); Set<Integer> set = new HashSet<Integer>(); // HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to // a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not // aware of the item yet // IT should be noted that -1 will fail the gate further down, if an entry already exists with // value -1 for this name. This is what is broken and being warned about. // APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes // - you can't make them properly until you've registered with the game. ResourceLocation registryName = stack.getItem().delegate.name(); int id; if (registryName == null) { FMLLog.log( Level.DEBUG, "Attempted to find the oreIDs for an unregistered object (%s). This won't work very well.", stack); return new int[0]; } else { id = GameData.getItemRegistry().getId(registryName); } List<Integer> ids = stackToId.get(id); if (ids != null) set.addAll(ids); ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16)); if (ids != null) set.addAll(ids); Integer[] tmp = set.toArray(new Integer[set.size()]); int[] ret = new int[tmp.length]; for (int x = 0; x < tmp.length; x++) ret[x] = tmp[x]; return ret; }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { // Stop the epic channel closed spam at close if (!(cause instanceof ClosedChannelException)) { FMLLog.log(Level.ERROR, cause, "NetworkDispatcher exception"); } super.exceptionCaught(ctx, cause); }
public static TileEntity func_190200_a(World p_190200_0_, NBTTagCompound p_190200_1_) { TileEntity tileentity = null; String s = p_190200_1_.getString("id"); Class<? extends TileEntity> oclass = null; try { oclass = nameToClassMap.get(s); if (oclass != null) { tileentity = (TileEntity) oclass.newInstance(); } } catch (Throwable throwable1) { LOGGER.error("Failed to create block entity {}", new Object[] {s, throwable1}); net.minecraftforge.fml.common.FMLLog.log( org.apache.logging.log4j.Level.ERROR, throwable1, "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", s, oclass.getName()); } if (tileentity != null) { try { tileentity.func_190201_b(p_190200_0_); tileentity.readFromNBT(p_190200_1_); } catch (Throwable throwable) { LOGGER.error("Failed to load data for block entity {}", new Object[] {s, throwable}); net.minecraftforge.fml.common.FMLLog.log( org.apache.logging.log4j.Level.ERROR, throwable, "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", s, oclass.getName()); tileentity = null; } } else { LOGGER.warn("Skipping BlockEntity with id {}", new Object[] {s}); } return tileentity; }
/** * Adds a Chapter (or overrides one that already exists) * * @param chapter Chapter to add */ public void addChapter(Chapter chapter) { for (Chapter chap : chapters) if (chap.identifier.equals(chapter.identifier)) { chap = chapter; return; } if (chapters.length < 7) { Chapter[] newchap = new Chapter[chapters.length + 1]; for (int i = 0; i < chapters.length; i++) newchap[i] = chapters[i]; newchap[chapters.length] = chapter; chapters = newchap; } else FMLLog.log( "AbyssalCraftAPI", Level.ERROR, "NecroData instance is already full, can't add a new Chapter!"); }
/** ■視線先のEntityを捕捉する EntityRender.getMouseOver()をぱくぱく */ @Override public List<MovingObjectPosition> getEntity(ItemStack itemStackIn, EntityPlayer playerIn) { List<MovingObjectPosition> targets = new ArrayList<MovingObjectPosition>(); // new ArrayList<MovingObjectPosition>(); if (playerIn != null && playerIn.worldObj != null) { MovingObjectPosition blockMOP = null; // ■りふれくしょん! Timer timer; try { timer = ObfuscationReflectionHelper.getPrivateValue( Minecraft.class, Minecraft.getMinecraft(), 19); } catch (UnableToAccessFieldException e) { FMLLog.log(Level.ERROR, e, "りふれくしょん! に失敗しました!>< ClientProxy.getEntity()"); throw e; } // ■レンジ(チンッ!) double range = 20d; // ■直近のブロックとの距離 double nearBlockRange = 0; // ■れいとれーす! // (プレイヤーの視線の先で最寄のブロックまでの距離を返す。 // ブロックが無かったら指定したレンジぐらいのアタイ!を返す) // TODO 奈落とか天上だとどうなるか要検証 blockMOP = playerIn.rayTrace(range, timer.renderPartialTicks); // ■プレイヤーの視点位置 // (renderPartialTicks:0.0 - 1.0) 一回前の描画位置からどれだけ動いたかの比率(?)として使ってる(?) Vec3 playerEyePos = playerIn.getPositionEyes(timer.renderPartialTicks); // ■入手したモップがある if (blockMOP != null) { // ■「プレイヤーの視点」と「最寄ブロック」との距離を取得 nearBlockRange = blockMOP.hitVec.distanceTo(playerEyePos); } // ■プレイヤーの視線(単位ベクトル)(ベクトルに乗算するメソッドが無い事に驚愕) Vec3 playerSight = playerIn.getLook(timer.renderPartialTicks); // ■プレイヤーの視線(レンジ) Vec3 playerRange = playerEyePos.addVector( playerSight.xCoord * range, playerSight.yCoord * range, playerSight.zCoord * range); // ■プレイヤーの視線(立方体)に入っているEntityをかき集める float f1 = 1.0f; // 立方体拡張(上下に1.0F) AxisAlignedBB aabb1 = playerIn .getEntityBoundingBox() .addCoord( playerSight.xCoord * range, playerSight.yCoord * range, playerSight.zCoord * range) .expand(f1, f1, f1); List<Entity> list = playerIn.worldObj.getEntitiesWithinAABBExcludingEntity(playerIn, aabb1); // TODO ごり押し君(SOWはEntityWeatherの為) list.addAll(playerIn.worldObj.weatherEffects); // ■Entity! 君に決めた! 枠 Entity mob = null; Vec3 mobDist = null; double mobRange = nearBlockRange; Entity sow = null; Vec3 sowDist = null; double sowRange = nearBlockRange; // ■かき集めたEntity共をチェックしていく(candidate:候補者) for (Entity candidate : list) { // ■「判定なし」かつ「SOWでは無い」を満たすEntityはスルー // if (!candidate.canBeCollidedWith() && !(candidate instanceof EntitySOW)) { continue; } // ■ドラゴン(概念)は対象外 if (candidate instanceof EntityDragon) { continue; } // ■「not 生物」かつ「not ドラゴンパーツ」かつ「not SOW」を満たすEntityはスルー if (!(candidate instanceof EntityLivingBase) && !(candidate instanceof EntityDragonPart) && !(candidate instanceof EntitySOW)) { continue; } // ■ターゲットの当たり判定を拡張 float fExpand = candidate.getCollisionBorderSize() * 3f; AxisAlignedBB aabb2 = candidate.getEntityBoundingBox().expand(fExpand, fExpand, fExpand); // ■拡張したターゲットの当たり判定と視線(レンジ)が交差するなら、モップが帰る MovingObjectPosition targetMOP = aabb2.calculateIntercept(playerEyePos, playerRange); // ■ターゲットの中、あったかいナリ(当たり判定が重なってる) if (aabb2.isVecInside(playerEyePos)) { // ■Entityの種類によって格納するインスタンスを分ける if (candidate instanceof EntitySOW) { // ■距離が近いので更新 if (0.0D < sowRange || sowRange == 0.0D) { sow = candidate; sowDist = targetMOP == null ? playerEyePos : targetMOP.hitVec; sowRange = 0.0D; } } else { // ■距離が近いので更新 if (0.0D < mobRange || mobRange == 0.0D) { mob = candidate; mobDist = targetMOP == null ? playerEyePos : targetMOP.hitVec; mobRange = 0.0D; } } } // ■帰ってきたモップ else if (targetMOP != null) { double range2 = playerEyePos.distanceTo(targetMOP.hitVec); // ■前に調べた奴より距離が近い if (candidate instanceof EntitySOW) { if (range2 < sowRange || sowRange == 0.0D) { sow = candidate; sowDist = targetMOP.hitVec; sowRange = range2; } } else { if (range2 < mobRange || mobRange == 0.0D) { // ■現在乗ってるEntity かつ 対象Entityに乗った状態で右クリックが有効か否か(このメソッド、使えそう) if (candidate == playerIn.ridingEntity && !candidate.canRiderInteract()) { // TODO このシーケンスには入れるの? if (mobRange == 0.0D) { mob = candidate; mobDist = targetMOP.hitVec; } } else { mob = candidate; mobDist = targetMOP.hitVec; mobRange = range2; } } } } } // ■調べ終えました。 // 「ターゲット」が居る かつ // (「ターゲットの間にブロックが無い」 または // 「モップがヌルポ(TODO どうやったらこの条件になるか要検証)」) if (mob != null && (mobRange < nearBlockRange || blockMOP == null)) { // mop = new MovingObjectPosition(mob, mobDist); targets.add(new MovingObjectPosition(mob, mobDist)); // TODO // System.out.println("targets.add(mob) = " + mob.getName()); } if (sow != null && (sowRange < nearBlockRange || blockMOP == null)) { targets.add(new MovingObjectPosition(sow, sowDist)); // TODO // System.out.println("targets.add(sow) = " + sow.getName()); } } return targets; }
public void abortClientHandshake(String type) { FMLLog.log(Level.INFO, "Aborting client handshake \"%s\"", type); // FMLCommonHandler.instance().waitForPlayClient(); completeClientSideConnection(ConnectionType.valueOf(type)); }