@Nullable public FluidStack getFluid() { Item item = container.getItem(); if (item == Items.WATER_BUCKET) { return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME); } else if (item == Items.LAVA_BUCKET) { return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME); } else if (item == Items.MILK_BUCKET) { return FluidRegistry.getFluidStack("milk", Fluid.BUCKET_VOLUME); } else if (item == ForgeModContainer.getInstance().universalBucket) { return ForgeModContainer.getInstance().universalBucket.getFluid(container); } else { return null; } }
protected void setFluid(Fluid fluid) { if (fluid == null) { container.deserializeNBT(new ItemStack(Items.BUCKET).serializeNBT()); } else if (fluid == FluidRegistry.WATER) { container.deserializeNBT(new ItemStack(Items.WATER_BUCKET).serializeNBT()); } else if (fluid == FluidRegistry.LAVA) { container.deserializeNBT(new ItemStack(Items.LAVA_BUCKET).serializeNBT()); } else if (fluid.getName().equals("milk")) { container.deserializeNBT(new ItemStack(Items.MILK_BUCKET).serializeNBT()); } else if (FluidRegistry.isUniversalBucketEnabled() && FluidRegistry.getBucketFluids().contains(fluid)) { ItemStack filledBucket = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid); container.deserializeNBT(filledBucket.serializeNBT()); } }
@Override public boolean renderModelFlat(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer buffer, boolean checkSides, long rand) { if(ForgeModContainer.forgeLightPipelineEnabled) { if(buffer != lastRendererFlat.get()) { lastRendererFlat.set(buffer); VertexBufferConsumer newCons = new VertexBufferConsumer(buffer); wrFlat.set(newCons); lighterFlat.get().setParent(newCons); } wrFlat.get().setOffset(pos); return render(lighterFlat.get(), world, model, state, pos, buffer, checkSides, rand); } else { return super.renderModelFlat(world, model, state, pos, buffer, checkSides, rand); } }
@Override public boolean renderModelSmooth(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer buffer, boolean checkSides, long rand) { if(ForgeModContainer.forgeLightPipelineEnabled) { if(buffer != lastRendererSmooth.get()) { lastRendererSmooth.set(buffer); VertexBufferConsumer newCons = new VertexBufferConsumer(buffer); wrSmooth.set(newCons); lighterSmooth.get().setParent(newCons); } wrSmooth.get().setOffset(pos); return render(lighterSmooth.get(), world, model, state, pos, buffer, checkSides, rand); } else { return super.renderModelSmooth(world, model, state, pos, buffer, checkSides, rand); } }
/** * Draws the screen and all the components in it. */ @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { if (showNotification == null || !showNotification.shouldDraw() || ForgeModContainer.disableVersionCheck) { return; } Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS); GlStateManager.color(1, 1, 1, 1); GlStateManager.pushMatrix(); int x = modButton.xPosition; int y = modButton.yPosition; int w = modButton.width; int h = modButton.height; drawModalRectWithCustomSizedTexture(x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16); GlStateManager.popMatrix(); }
public Fluid setBlock(Block block) { if (this.block == null || this.block == block) { this.block = block; } else if (!ForgeModContainer.forceDuplicateFluidBlockCrash) { FMLLog.warning("A mod has attempted to assign Block " + block + " to the Fluid '" + fluidName + "' but this Fluid has already been linked to BlockID " + this.block + ". Configure your mods to prevent this from happening."); } else { FMLLog.severe("A mod has attempted to assign BlockID " + block + " to the Fluid '" + fluidName + "' but this Fluid has already been linked to BlockID " + this.block + ". Configure your mods to prevent this from happening."); throw new LoaderException(new RuntimeException("A mod has attempted to assign BlockID " + block + " to the Fluid '" + fluidName + "' but this Fluid has already been linked to BlockID " + this.block + ". Configure your mods to prevent this from happening.")); } return this; }
public static void createDisplay() throws LWJGLException { ImageIO.setUseCache(false); //Disable on-disc stream cache should speed up texture pack reloading. PixelFormat format = new PixelFormat().withDepthBits(24); if (!ForgeModContainer.enableStencilBits || Boolean.parseBoolean(System.getProperty("forge.forceNoStencil", "false"))) { Display.create(format); stencilBits = 0; return; } try { //TODO: Figure out how to determine the max bits. Display.create(format.withStencilBits(8)); stencilBits = 8; } catch(LWJGLException e) { Display.create(format); stencilBits = 0; } }
public void init() { MinecraftForge.EVENT_BUS.register(new NetworkHandler()); PlayerHandlers.PlayerSleepHandler sleepHandler = new PlayerHandlers.PlayerSleepHandler(); PlayerHandlers.PlayerRespawnHandler respawnHandler = new PlayerHandlers.PlayerRespawnHandler(); MinecraftForge.EVENT_BUS.register(sleepHandler); MinecraftForge.EVENT_BUS.register(respawnHandler); MinecraftForge.EVENT_BUS.register(new EntityHandlers.EnderPearlHandler()); MinecraftForge.EVENT_BUS.register(new EntityHandlers.LivingAttackHandler()); MinecraftForge.EVENT_BUS.register(new EntityHandlers.MobHandler()); MinecraftForge.EVENT_BUS.register(new EntityHandlers.LivingHurtHandler()); MinecraftForge.EVENT_BUS.register(new WorldHandlers.ExplosionHandler()); MinecraftForge.EVENT_BUS.register(new WorldHandlers.WorldPotentialSpawnsHandler()); InitMobRegistry.init(); InitLightLevels.tweakLightValues(); if (!Settings.enableSpawnFuzz[1]) { ForgeModContainer.defaultHasSpawnFuzz = false; } }
@Override protected void applyEntityAttributes() { super.applyEntityAttributes(); getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); getAttributeMap().registerAttribute(spawnReinforcementsAttribute).setBaseValue(rand.nextDouble() * ForgeModContainer.zombieSummonBaseChance); if(ACConfig.hardcoreMode){ getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(80.0D); getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); } else { getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(40.0D); getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D); } }
public static void init(){ if(initDone) return; FuelRegistry.getInstance().registerFuel(cyano.basemetals.init.Items.carbon_powder,(short)1600); ItemStack bucket = new ItemStack(ForgeModContainer.getInstance().universalBucket); FuelRegistry.getInstance().registerFuel(ForgeModContainer.getInstance().universalBucket,(ItemStack ub)->{ if(ub.getItem() instanceof UniversalBucket){ UniversalBucket ubItem = (UniversalBucket) ub.getItem(); FluidStack fs = ubItem.getFluid(ub); if (fs != null && fs.amount > 0){ if(fs.getFluid() == Fluids.crude_oil) return (short)(fs.amount * CRUDE_OIL_FUEL_PER_FLUID_UNIT); if(fs.getFluid() == Fluids.refined_oil) return (short)(fs.amount * REFINED_OIL_FUEL_PER_FLUID_UNIT); } } return (short)0; }); FuelRegistry.getInstance().registerPostBurnItem(ForgeModContainer.getInstance().universalBucket,(ItemStack sb)->new ItemStack(net.minecraft.init.Items.BUCKET)); initDone = true; }
public static void init() { liquidMana = registerFluid(liquidMana); liquidWaterSource = registerFluid(liquidWaterSource); liquidGrass = registerFluid(liquidGrass); liquidFire = registerFluid(liquidFire); FluidRegistry.addBucketForFluid(liquidMana); FluidRegistry.addBucketForFluid(liquidWaterSource); FluidRegistry.addBucketForFluid(liquidGrass); FluidRegistry.addBucketForFluid(liquidFire); bucketMana = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, liquidMana); bucketFire = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, liquidFire); bucketGrass = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, liquidGrass); bucketWaterSource = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, liquidWaterSource); bucketMana.getItem().setCreativeTab(powerofmagic.tabpowerofmagic); bucketFire.getItem().setCreativeTab(powerofmagic.tabpowerofmagic); bucketGrass.getItem().setCreativeTab(powerofmagic.tabpowerofmagic); bucketWaterSource.getItem().setCreativeTab(powerofmagic.tabpowerofmagic); }
@Override public void onEnabled() { previousForgeLightPipelineEnabled = ForgeModContainer.forgeLightPipelineEnabled; ForgeModContainer.forgeLightPipelineEnabled = false; ForgeHaxHooks.COLOR_MULTIPLIER_ALPHA = (this.opacity.getAsFloat() / 255.f); ForgeHaxHooks.SHOULD_UPDATE_ALPHA = true; reloadChunks(); ForgeHaxHooks.SHOULD_DISABLE_CAVE_CULLING.enable(); }
@Override public void onDisabled() { ForgeModContainer.forgeLightPipelineEnabled = previousForgeLightPipelineEnabled; ForgeHaxHooks.SHOULD_UPDATE_ALPHA = false; reloadChunks(); ForgeHaxHooks.SHOULD_DISABLE_CAVE_CULLING.disable(); }
@Override protected GuiScreen buildChildScreen() { // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. The parent // GuiConfig object's entryList will also be refreshed to reflect the changes. return new GuiConfig(this.owningScreen, (new ConfigElement(ForgeModContainer.getConfig().getCategory(Configuration.CATEGORY_GENERAL))).getChildElements(), this.owningScreen.modID, Configuration.CATEGORY_GENERAL, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeModContainer.getConfig().toString())); }
@Override protected GuiScreen buildChildScreen() { // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. The parent // GuiConfig object's entryList will also be refreshed to reflect the changes. return new GuiConfig(this.owningScreen, (new ConfigElement(ForgeModContainer.getConfig().getCategory(Configuration.CATEGORY_CLIENT))).getChildElements(), this.owningScreen.modID, Configuration.CATEGORY_CLIENT, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeModContainer.getConfig().toString())); }
@Override protected GuiScreen buildChildScreen() { ConfigCategory cfg = ForgeModContainer.getConfig().getCategory(VERSION_CHECK_CAT); Map<String, Property> values = new HashMap<String, Property>(cfg.getValues()); values.remove("Global"); Property global = ForgeModContainer.getConfig().get(VERSION_CHECK_CAT, "Global", true); List<Property> props = new ArrayList<Property>(); for (ModContainer mod : ForgeVersion.gatherMods().keySet()) { values.remove(mod.getModId()); props.add(ForgeModContainer.getConfig().get(VERSION_CHECK_CAT, mod.getModId(), true)); //Get or make the value in the config } props.addAll(values.values()); // Add any left overs from the config Collections.sort(props, new Comparator<Property>() { @Override public int compare(Property o1, Property o2) { return o1.getName().compareTo(o2.getName()); } }); List<IConfigElement> list = new ArrayList<IConfigElement>(); list.add(new ConfigElement(global)); for (Property prop : props) { list.add(new ConfigElement(prop)); } // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. The parent // GuiConfig object's propertyList will also be refreshed to reflect the changes. return new GuiConfig(this.owningScreen, list, this.owningScreen.modID, VERSION_CHECK_CAT, true, true, GuiConfig.getAbridgedConfigPath(ForgeModContainer.getConfig().toString())); }
public static void registerChannel(ForgeModContainer forgeModContainer, Side side) { channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec()); if (side == Side.CLIENT) { addClientHandlers(); } FMLEmbeddedChannel serverChannel = channelPair.get(Side.SERVER); serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE); String handlerName = serverChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class); serverChannel.pipeline().addAfter(handlerName, "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler()); }
public static void createBuckets() { for(Fluid fluid : bucketFluids){ if (FluidRegistry.isUniversalBucketEnabled()) { FluidRegistry.addBucketForFluid(fluid); bucketList.put(fluid, UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid)); } else { bucketList.put(fluid, new ItemStack(ItemBucketCrystalMod.create(null, fluid))); } } }
public void register() { GameRegistry.register(this); GameRegistry.register(new ItemBlock(this), this.getRegistryName()); CraftingManager.getInstance().addRecipe(new ShapedOreRecipe( new ItemStack(Item.getItemFromBlock(this), 9), "hs", "wc", 'h', Blocks.HAY_BLOCK, 's', UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, FluidsRegistry.sewage), 'c', Blocks.CLAY, 'w', Items.WATER_BUCKET )); }
protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D); this.getAttributeMap().registerAttribute(field_110186_bp).setBaseValue(this.rand.nextDouble() * ForgeModContainer.zombieSummonBaseChance); }
@Override protected GuiScreen buildChildScreen() { // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. The parent // GuiConfig object's entryList will also be refreshed to reflect the changes. return new GuiConfig(this.owningScreen, (new ConfigElement(ConfigHandler.config.getCategory(ConfigHandler.CATEGORY_FUNCTION)).getChildElements()), this.owningScreen.modID, ConfigHandler.CATEGORY_FUNCTION, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeModContainer.getConfig().toString())); }
@Override protected GuiScreen buildChildScreen() { return new GuiConfig(this.owningScreen, (new ConfigElement(ConfigHandler.config.getCategory(ConfigHandler.CATEGORY_LOAD)).getChildElements()), this.owningScreen.modID, ConfigHandler.CATEGORY_FUNCTION, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeModContainer.getConfig().toString())); }
@Override protected GuiScreen buildChildScreen() { return new GuiConfig(this.owningScreen, (new ConfigElement(ConfigHandler.config.getCategory(ConfigHandler.CATEGORY_MISC)).getChildElements()), this.owningScreen.modID, ConfigHandler.CATEGORY_MISC, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeModContainer.getConfig().toString())); }
@Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData par1EntityLivingData) { Object data = super.onInitialSpawn(difficulty, par1EntityLivingData); setShoggothType(0); if(world.provider.getDimension() == ACLib.abyssal_wasteland_id) setShoggothType(1); if(world.provider.getDimension() == ACLib.dreadlands_id) setShoggothType(2); if(world.provider.getDimension() == ACLib.omothol_id) setShoggothType(3); if(world.provider.getDimension() == ACLib.dark_realm_id) setShoggothType(4); if (data == null) data = new EntityLesserShoggoth.GroupData(world.rand.nextFloat() < ForgeModContainer.zombieBabyChance, null); if (data instanceof EntityLesserShoggoth.GroupData) { EntityLesserShoggoth.GroupData groupdata = (EntityLesserShoggoth.GroupData)data; if (groupdata.isBaby) setChild(true); } return (IEntityLivingData)data; }
@Override public boolean isItemValidForSlot(final int slot, final ItemStack item) { if(this.getInventory() == null) return false; if(slot >= this.getInventory().length) return false; if(item.getItem() == ForgeModContainer.getInstance().universalBucket) return true; return FluidContainerRegistry.isFilledContainer(item) && FluidContainerRegistry.getFluidForFilledItem(item) != null; }