@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { if (this.state != null) { FMLLog.getLogger() .log( Level.INFO, "Opening channel which already seems to have a state set. This is a vanilla connection. Handshake handler will stop now"); return; } FMLLog.getLogger().log(Level.TRACE, "Handshake channel activating"); this.state = ConnectionState.OPENING; // send ourselves as a user event, to kick the pipeline active this.handshakeChannel.pipeline().fireUserEventTriggered(this); this.manager.channel().config().setAutoRead(true); }
public WeightedRandomModel(ModelResourceLocation parent, Variants variants) { this.variants = variants.getVariants(); ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder(); for (Variant v : (List<Variant>) variants.getVariants()) { ResourceLocation loc = v.getModelLocation(); locations.add(loc); IModel model = null; try { model = getModel(loc); } catch (Exception e) { /* * Vanilla eats this, which makes it only show variants that have models. * But that doesn't help debugging, so we maintain the missing model * so that resource pack makers have a hint that their states are broken. */ FMLLog.warning( "Unable to load block model: \'" + loc + "\' for variant: \'" + parent + "\': " + e.toString()); model = getMissingModel(); } if (v instanceof ISmartVariant) { model = ((ISmartVariant) v).process(model, ModelLoader.this); try { resolveDependencies(model); } catch (IOException e) { FMLLog.getLogger() .error("Exception resolving indirect dependencies for model" + loc, e); } textures.addAll(model.getTextures()); // Kick this, just in case. } models.add(model); builder.add(Pair.of(model, v.getState())); } if (models.size() == 0) // If all variants are missing, add one with the missing model and default rotation. { IModel missing = getMissingModel(); models.add(missing); builder.add(Pair.<IModel, IModelState>of(missing, TRSRTransformation.identity())); } defaultState = new MultiModelState(builder.build()); }
private void loadItems() { registerVariantNames(); int size = 0; ImmutableList<Item> items = ImmutableList.copyOf(GameData.getItemRegistry().typeSafeIterable()); for (Item item : items) { size += getVariantNames(item).size(); } itemBar = ProgressManager.push("ModelLoader: items", size); for (Item item : items) { // default loading for (String s : (List<String>) getVariantNames(item)) { ResourceLocation file = getItemLocation(s); ModelResourceLocation memory = getInventoryVariant(s); itemBar.step(memory.toString()); IModel model = null; try { model = getModel(file); } catch (IOException e) { // Handled by our finally block. } finally { if (model == null || model == getMissingModel()) { FMLLog.fine( "Item json isn't found for '" + memory + "', trying to load the variant from the blockstate json"); try { registerVariant(getModelBlockDefinition(memory), memory); } catch (Exception exception) { FMLLog.getLogger().warn("Unable to load definition " + memory, exception); } } else stateModels.put(memory, model); } } } ProgressManager.pop(itemBar); // replace vanilla bucket models if desired. done afterwards for performance reasons if (ForgeModContainer.replaceVanillaBucketModel) { // ensure the bucket model is loaded if (!stateModels.containsKey(ModelDynBucket.LOCATION)) { // load forges blockstate json for it ModelResourceLocation memory = getInventoryVariant("forge:dynbucket"); registerVariant(getModelBlockDefinition(memory), memory); } // empty bucket for (String s : getVariantNames(Items.bucket)) { ModelResourceLocation memory = getInventoryVariant(s); try { IModel model = getModel(new ResourceLocation("forge", "item/bucket")); // only on successful load, otherwise continue using the old model stateModels.put(memory, model); } catch (IOException e) { // use the original vanilla model } } setBucketModel(Items.water_bucket); setBucketModel(Items.lava_bucket); // milk bucket only replaced if some mod adds milk if (FluidRegistry.isFluidRegistered("milk")) { // can the milk be put into a bucket? Fluid milk = FluidRegistry.getFluid("milk"); FluidStack milkStack = new FluidStack(milk, FluidContainerRegistry.BUCKET_VOLUME); if (FluidContainerRegistry.getContainerCapacity(milkStack, new ItemStack(Items.bucket)) == FluidContainerRegistry.BUCKET_VOLUME) { setBucketModel(Items.milk_bucket); } } else { // milk bucket if no milk fluid is present for (String s : getVariantNames(Items.milk_bucket)) { ModelResourceLocation memory = getInventoryVariant(s); try { IModel model = getModel(new ResourceLocation("forge", "item/bucket_milk")); // only on successful load, otherwise continue using the old model stateModels.put(memory, model); } catch (IOException e) { // use the original vanilla model } } } } }