From fa4a0e726112c34a9d311ec03992b37fde94bbd7 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 5 Mar 2022 01:45:39 -0800 Subject: [PATCH] Limiting the infinite - Add new config and tags for better control over infinite draining behaviour - Pipes spilling water will now extinguish entities and fires; pipes spilling lava will now set entities on fire - Fix some bugs and inconvenient behavior with the config menus - Fix fluids destroying crushing wheel controllers - Fix crushing wheel controller using output direction instead of input direction at times - Rename blaze burner fuel tags - Improve GhostBlockRenderer - Organize imports - Update Forge --- gradle.properties | 2 +- src/generated/resources/.cache/cache | 9 +- .../data/create/advancements/aesthetics.json | 4 +- .../blocks/crushing_wheel_controller.json | 20 --- .../create/tags/fluids/bottomless/allow.json | 7 + .../bottomless/deny.json} | 0 .../tags/items/blaze_burner_fuel/regular.json | 4 + .../special.json} | 0 .../java/com/simibubi/create/AllBlocks.java | 7 +- .../java/com/simibubi/create/AllItems.java | 2 +- .../java/com/simibubi/create/AllTags.java | 16 ++- .../simibubi/create/compat/jei/CreateJEI.java | 58 ++++++-- .../category/MechanicalCraftingCategory.java | 1 - .../CrushingWheelControllerTileEntity.java | 10 +- .../mixer/MechanicalMixerTileEntity.java | 1 - .../glue/SuperGlueHandler.java | 2 +- .../contraptions/fluids/OpenEndedPipe.java | 75 +++++++++-- .../actors/FluidManipulationBehaviour.java | 32 ++++- .../particle/AirFlowParticle.java | 10 +- .../burner/BlazeBurnerTileEntity.java | 4 +- .../curiosities/tools/BlueprintItem.java | 1 - .../block/SchematicannonTileEntity.java | 4 +- .../create/foundation/config/CFluids.java | 15 ++- .../config/ui/BaseConfigScreen.java | 27 ++-- .../config/ui/ConfigModListScreen.java | 17 ++- .../foundation/config/ui/ConfigScreen.java | 6 +- .../config/ui/OpenCreateMenuButton.java | 4 +- .../config/ui/SubMenuConfigScreen.java | 30 ++--- .../foundation/data/SharedProperties.java | 5 +- .../MechanicalCraftingRecipeBuilder.java | 2 - .../foundation/gui/AbstractSimiScreen.java | 30 ++--- .../foundation/gui/ConfirmationScreen.java | 26 ++-- .../foundation/gui/CreateMainMenuScreen.java | 40 +++--- .../simibubi/create/foundation/gui/Theme.java | 64 ++++----- .../belt/DirectBeltInputBehaviour.java | 2 +- .../utility/ghost/GhostBlockRenderer.java | 124 +++++------------- 36 files changed, 353 insertions(+), 308 deletions(-) delete mode 100644 src/generated/resources/data/create/loot_tables/blocks/crushing_wheel_controller.json create mode 100644 src/generated/resources/data/create/tags/fluids/bottomless/allow.json rename src/generated/resources/data/create/tags/{items/blaze_burner_regular_fuel.json => fluids/bottomless/deny.json} (100%) create mode 100644 src/generated/resources/data/create/tags/items/blaze_burner_fuel/regular.json rename src/generated/resources/data/create/tags/items/{blaze_burner_special_fuel.json => blaze_burner_fuel/special.json} (100%) diff --git a/gradle.properties b/gradle.properties index 0e9349580..e6e763315 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon = false # mod version info mod_version = 0.4d minecraft_version = 1.18.1 -forge_version = 39.0.59 +forge_version = 39.1.0 # build dependency versions forgegradle_version = 5.1.+ diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 72d0b3679..7335af5d9 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -2126,7 +2126,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 5049f72c327a88f175f6f9425909e098fc711100 assets/create/sounds.json -5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json +0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json 613e64b44bed959da899fdd54c1cacb227fb33f2 data/create/advancements/andesite_alloy.json 81885c6bfb85792c88aaa7c9b70f58832945d31f data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json @@ -3339,7 +3339,6 @@ c633372228a13023f9dde2cd3478a7dc90affcea data/create/loot_tables/blocks/crimsite 62800d2baf79e7a45b246896f2679fd6f5082efe data/create/loot_tables/blocks/crimson_window.json 572dfdf4daaaf2c97882f3b2a856737365bf5873 data/create/loot_tables/blocks/crimson_window_pane.json 3503b55a82b94ddaeebbc510eece2cc313c33e43 data/create/loot_tables/blocks/crushing_wheel.json -5c1df8443043b3fe3b665dba348e2ff188bcbe31 data/create/loot_tables/blocks/crushing_wheel_controller.json 252a6476bd2dd730dd97afbf2c69d9627f0d1672 data/create/loot_tables/blocks/cuckoo_clock.json 838c008dc2881fbb4136773b3c84c3d988483f73 data/create/loot_tables/blocks/cut_andesite.json accd5aecce569330b1821d12f031a68259a42f27 data/create/loot_tables/blocks/cut_andesite_brick_slab.json @@ -5194,8 +5193,10 @@ d063e12c9ef75f39518c6d129ea35d833464d547 data/create/tags/blocks/toolboxes.json eac71740fb12bdb38b5dfaa2268613d7ba82b809 data/create/tags/blocks/windmill_sails.json 74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/blocks/windowable.json 893a01e6004d6d8272bd1658e98da88bb572ee57 data/create/tags/blocks/wrench_pickup.json -74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/items/blaze_burner_regular_fuel.json -97061ef67cac1fafd869493d06115b968bcb99bf data/create/tags/items/blaze_burner_special_fuel.json +a8bdc387cfa6296ebcc4af14323e2ddb632234dc data/create/tags/fluids/bottomless/allow.json +74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/fluids/bottomless/deny.json +74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/items/blaze_burner_fuel/regular.json +97061ef67cac1fafd869493d06115b968bcb99bf data/create/tags/items/blaze_burner_fuel/special.json 5212172aee2239136c94f9868ad39ec2e17cf1c6 data/create/tags/items/create_ingots.json 4480f211f4a37bfee193eba945bc9f5a8d2c6e34 data/create/tags/items/crushed_ores.json bce28787b0271382842823d04a977912a88b01c2 data/create/tags/items/sandpaper.json diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index 59a86f429..d723cbe38 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -28,8 +28,8 @@ "trigger": "create:bracket_apply", "conditions": { "accepted_entries": [ - "create:large_cogwheel", - "create:cogwheel" + "create:cogwheel", + "create:large_cogwheel" ] } }, diff --git a/src/generated/resources/data/create/loot_tables/blocks/crushing_wheel_controller.json b/src/generated/resources/data/create/loot_tables/blocks/crushing_wheel_controller.json deleted file mode 100644 index 3da3a59b4..000000000 --- a/src/generated/resources/data/create/loot_tables/blocks/crushing_wheel_controller.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1.0, - "bonus_rolls": 0.0, - "entries": [ - { - "type": "minecraft:item", - "name": "minecraft:air" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/create/tags/fluids/bottomless/allow.json b/src/generated/resources/data/create/tags/fluids/bottomless/allow.json new file mode 100644 index 000000000..8c09104dc --- /dev/null +++ b/src/generated/resources/data/create/tags/fluids/bottomless/allow.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "minecraft:water", + "minecraft:lava" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/tags/items/blaze_burner_regular_fuel.json b/src/generated/resources/data/create/tags/fluids/bottomless/deny.json similarity index 100% rename from src/generated/resources/data/create/tags/items/blaze_burner_regular_fuel.json rename to src/generated/resources/data/create/tags/fluids/bottomless/deny.json diff --git a/src/generated/resources/data/create/tags/items/blaze_burner_fuel/regular.json b/src/generated/resources/data/create/tags/items/blaze_burner_fuel/regular.json new file mode 100644 index 000000000..5e8aecc98 --- /dev/null +++ b/src/generated/resources/data/create/tags/items/blaze_burner_fuel/regular.json @@ -0,0 +1,4 @@ +{ + "replace": false, + "values": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/tags/items/blaze_burner_special_fuel.json b/src/generated/resources/data/create/tags/items/blaze_burner_fuel/special.json similarity index 100% rename from src/generated/resources/data/create/tags/items/blaze_burner_special_fuel.json rename to src/generated/resources/data/create/tags/items/blaze_burner_fuel/special.json diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 60f0bb6fc..f17891f3d 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -399,7 +399,7 @@ public class AllBlocks { .register(); public static final BlockEntry BELT = REGISTRATE.block("belt", BeltBlock::new) - .initialProperties(SharedProperties.beltMaterial, MaterialColor.COLOR_GRAY) + .initialProperties(SharedProperties.BELT_MATERIAL, MaterialColor.COLOR_GRAY) .properties(p -> p.sound(SoundType.WOOL)) .properties(p -> p.strength(0.8F)) .transform(axeOrPickaxe()) @@ -506,7 +506,8 @@ public class AllBlocks { public static final BlockEntry CRUSHING_WHEEL_CONTROLLER = REGISTRATE.block("crushing_wheel_controller", CrushingWheelControllerBlock::new) - .initialProperties(() -> Blocks.AIR) + .initialProperties(SharedProperties.CRUSHING_WHEEL_CONTROLLER_MATERIAL) + .properties(p -> p.noOcclusion().noDrops().air()) .blockstate((c, p) -> p.getVariantBuilder(c.get()) .forAllStatesExcept(state -> ConfiguredModel.builder() .modelFile(p.models() @@ -909,7 +910,7 @@ public class AllBlocks { .register(); public static final BlockEntry ROPE = REGISTRATE.block("rope", PulleyBlock.RopeBlock::new) - .initialProperties(SharedProperties.beltMaterial, MaterialColor.COLOR_BROWN) + .initialProperties(SharedProperties.BELT_MATERIAL, MaterialColor.COLOR_BROWN) .tag(AllBlockTags.BRITTLE.tag) .properties(p -> p.sound(SoundType.WOOL)) .blockstate((c, p) -> p.simpleBlock(c.get(), p.models() diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index cbdb13591..15f812870 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -100,7 +100,7 @@ public class AllItems { .register(); public static final ItemEntry BLAZE_CAKE = REGISTRATE.item("blaze_cake", CombustibleItem::new) - .tag(AllItemTags.BLAZE_BURNER_SPECIAL_FUEL.tag, AllItemTags.UPRIGHT_ON_BELT.tag) + .tag(AllItemTags.BLAZE_BURNER_FUEL_SPECIAL.tag, AllItemTags.UPRIGHT_ON_BELT.tag) .onRegister(i -> i.setBurnTime(6400)) .register(); diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 27e7a6457..52082a021 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -26,6 +26,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.Tags; public class AllTags { @@ -81,7 +82,9 @@ public class AllTags { public enum NameSpace { - MOD(Create.ID, false, true), FORGE("forge"), TIC("tconstruct") + MOD(Create.ID, false, true), + FORGE("forge"), + TIC("tconstruct") ; @@ -183,8 +186,8 @@ public class AllTags { public enum AllItemTags { - BLAZE_BURNER_REGULAR_FUEL, - BLAZE_BURNER_SPECIAL_FUEL, + BLAZE_BURNER_FUEL_REGULAR(MOD, "blaze_burner_fuel/regular"), + BLAZE_BURNER_FUEL_SPECIAL(MOD, "blaze_burner_fuel/special"), CREATE_INGOTS, CRUSHED_ORES, SANDPAPER, @@ -255,7 +258,8 @@ public class AllTags { public enum AllFluidTags { - NO_INFINITE_DRAINING(MOD, true, false), + BOTTOMLESS_ALLOW(MOD, "bottomless/allow"), + BOTTOMLESS_DENY(MOD, "bottomless/deny"), HONEY(FORGE) @@ -314,12 +318,10 @@ public class AllTags { .addTag(child)); } - private static void loadClass() {} - } public static void register() { - AllFluidTags.loadClass(); + AllFluidTags.BOTTOMLESS_ALLOW.add(Fluids.WATER, Fluids.LAVA); AllItemTags.CREATE_INGOTS.includeIn(AllItemTags.BEACON_PAYMENT); AllItemTags.CREATE_INGOTS.includeIn(Tags.Items.INGOTS); diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index fb7aedf05..59f06d730 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -1,9 +1,42 @@ package com.simibubi.create.compat.jei; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; + import com.google.common.base.Predicates; -import com.simibubi.create.*; -import com.simibubi.create.compat.jei.category.*; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllFluids; +import com.simibubi.create.AllItems; +import com.simibubi.create.AllRecipeTypes; +import com.simibubi.create.Create; +import com.simibubi.create.compat.jei.category.BlockCuttingCategory; import com.simibubi.create.compat.jei.category.BlockCuttingCategory.CondensedBlockCuttingRecipe; +import com.simibubi.create.compat.jei.category.CreateRecipeCategory; +import com.simibubi.create.compat.jei.category.CrushingCategory; +import com.simibubi.create.compat.jei.category.DeployingCategory; +import com.simibubi.create.compat.jei.category.FanBlastingCategory; +import com.simibubi.create.compat.jei.category.FanHauntingCategory; +import com.simibubi.create.compat.jei.category.FanSmokingCategory; +import com.simibubi.create.compat.jei.category.FanWashingCategory; +import com.simibubi.create.compat.jei.category.ItemDrainCategory; +import com.simibubi.create.compat.jei.category.MechanicalCraftingCategory; +import com.simibubi.create.compat.jei.category.MillingCategory; +import com.simibubi.create.compat.jei.category.MixingCategory; +import com.simibubi.create.compat.jei.category.MysteriousItemConversionCategory; +import com.simibubi.create.compat.jei.category.PackingCategory; +import com.simibubi.create.compat.jei.category.PolishingCategory; +import com.simibubi.create.compat.jei.category.PressingCategory; +import com.simibubi.create.compat.jei.category.ProcessingViaFanCategory; +import com.simibubi.create.compat.jei.category.SawingCategory; +import com.simibubi.create.compat.jei.category.SequencedAssemblyCategory; +import com.simibubi.create.compat.jei.category.SpoutCategory; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCraftingRecipe; import com.simibubi.create.content.contraptions.components.deployer.DeployerApplicationRecipe; import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity; @@ -23,27 +56,24 @@ import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.VanillaRecipeCategoryUid; -import mezz.jei.api.registration.*; +import mezz.jei.api.registration.IGuiHandlerRegistration; +import mezz.jei.api.registration.IRecipeCatalystRegistration; +import mezz.jei.api.registration.IRecipeCategoryRegistration; +import mezz.jei.api.registration.IRecipeRegistration; +import mezz.jei.api.registration.IRecipeTransferRegistration; +import mezz.jei.api.registration.ISubtypeRegistration; import mezz.jei.api.runtime.IIngredientManager; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.*; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.ItemLike; import net.minecraftforge.common.crafting.IShapedRecipe; import net.minecraftforge.fml.ModList; -import javax.annotation.Nonnull; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - @JeiPlugin @SuppressWarnings("unused") public class CreateJEI implements IModPlugin { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java index 9aafdb81b..f2c362120 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java @@ -27,7 +27,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraftforge.common.crafting.IShapedRecipe; public class MechanicalCraftingCategory extends CreateRecipeCategory { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java index ba350f9ba..de30109ed 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java @@ -81,7 +81,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { if (blockState == null) return false; Direction direction = blockState.getValue(CrushingWheelControllerBlock.FACING); - return direction == Direction.DOWN || direction == side; + return direction == Direction.DOWN || direction.getOpposite() == side; } @Override @@ -144,21 +144,21 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { inventory.remainingTime = 0; // Output Items - if (facing.getAxis() - .isHorizontal() || facing == Direction.DOWN) { + if (facing != Direction.UP) { + Direction inputDir = facing.getOpposite(); BlockPos nextPos = worldPosition.offset(facing.getAxis() == Axis.X ? 1f * offset : 0f, (-1f), facing.getAxis() == Axis.Z ? 1f * offset : 0f); DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(level, nextPos, DirectBeltInputBehaviour.TYPE); if (behaviour != null) { boolean changed = false; - if (!behaviour.canInsertFromSide(facing)) + if (!behaviour.canInsertFromSide(inputDir)) return; for (int slot = 0; slot < inventory.getSlots(); slot++) { ItemStack stack = inventory.getStackInSlot(slot); if (stack.isEmpty()) continue; - ItemStack remainder = behaviour.handleInsertion(stack, facing, false); + ItemStack remainder = behaviour.handleInsertion(stack, inputDir, false); if (remainder.equals(stack, false)) continue; inventory.setStackInSlot(slot, remainder); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java index f5da5e418..14aa9da24 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java @@ -34,7 +34,6 @@ import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java index 30e916084..7d062dee7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java @@ -103,7 +103,7 @@ public class SuperGlueHandler { if (!world.isClientSide) { entity.playPlaceSound(); world.addFreshEntity(entity); - AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> entity), + AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> entity), new GlueEffectPacket(ray.getBlockPos(), face, true)); } itemstack.hurtAndBreak(1, placer, SuperGlueItem::onBroken); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java index 68f9c9e73..25921554b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java @@ -20,14 +20,18 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; +import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.AbstractCandleBlock; +import net.minecraft.world.level.block.CampfireBlock; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; @@ -46,6 +50,8 @@ public class OpenEndedPipe extends FlowSource { static { registerEffectHandler(new PotionEffectHandler()); registerEffectHandler(new MilkEffectHandler()); + registerEffectHandler(new WaterEffectHandler()); + registerEffectHandler(new LavaEffectHandler()); } private Level world; @@ -348,15 +354,15 @@ public class OpenEndedPipe extends FlowSource { if (pipe.cachedEffects.isEmpty()) return; - List list = + List entities = pipe.getWorld().getEntitiesOfClass(LivingEntity.class, pipe.getAOE(), LivingEntity::isAffectedByPotions); - for (LivingEntity livingentity : list) { - for (MobEffectInstance effectinstance : pipe.cachedEffects) { - MobEffect effect = effectinstance.getEffect(); + for (LivingEntity entity : entities) { + for (MobEffectInstance effectInstance : pipe.cachedEffects) { + MobEffect effect = effectInstance.getEffect(); if (effect.isInstantenous()) { - effect.applyInstantenousEffect(null, null, livingentity, effectinstance.getAmplifier(), 0.5D); + effect.applyInstantenousEffect(null, null, entity, effectInstance.getAmplifier(), 0.5D); } else { - livingentity.addEffect(new MobEffectInstance(effectinstance)); + entity.addEffect(new MobEffectInstance(effectInstance)); } } } @@ -366,7 +372,7 @@ public class OpenEndedPipe extends FlowSource { public static class MilkEffectHandler implements IEffectHandler { @Override public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { - return Tags.Fluids.MILK.contains(fluid.getFluid()); + return fluid.getFluid().is(Tags.Fluids.MILK); } @Override @@ -374,11 +380,60 @@ public class OpenEndedPipe extends FlowSource { Level world = pipe.getWorld(); if (world.getGameTime() % 5 != 0) return; - List list = + List entities = world.getEntitiesOfClass(LivingEntity.class, pipe.getAOE(), LivingEntity::isAffectedByPotions); ItemStack curativeItem = new ItemStack(Items.MILK_BUCKET); - for (LivingEntity livingentity : list) - livingentity.curePotionEffects(curativeItem); + for (LivingEntity entity : entities) + entity.curePotionEffects(curativeItem); + } + } + + public static class WaterEffectHandler implements IEffectHandler { + @Override + public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { + return fluid.getFluid().is(FluidTags.WATER); + } + + @Override + public void applyEffects(OpenEndedPipe pipe, FluidStack fluid) { + Level world = pipe.getWorld(); + if (world.getGameTime() % 5 != 0) + return; + List entities = world.getEntities((Entity) null, pipe.getAOE(), Entity::isOnFire); + for (Entity entity : entities) + entity.clearFire(); + BlockPos.betweenClosedStream(pipe.getAOE()).forEach(pos -> dowseFire(world, pos)); + } + + // Adapted from ThrownPotion + private static void dowseFire(Level level, BlockPos pos) { + BlockState state = level.getBlockState(pos); + if (state.is(BlockTags.FIRE)) { + level.removeBlock(pos, false); + } else if (AbstractCandleBlock.isLit(state)) { + AbstractCandleBlock.extinguish(null, state, level, pos); + } else if (CampfireBlock.isLitCampfire(state)) { + level.levelEvent(null, 1009, pos, 0); + CampfireBlock.dowse(null, level, pos, state); + level.setBlockAndUpdate(pos, state.setValue(CampfireBlock.LIT, false)); + } + } + } + + public static class LavaEffectHandler implements IEffectHandler { + @Override + public boolean canApplyEffects(OpenEndedPipe pipe, FluidStack fluid) { + return fluid.getFluid().is(FluidTags.LAVA); + } + + @Override + public void applyEffects(OpenEndedPipe pipe, FluidStack fluid) { + Level world = pipe.getWorld(); + if (world.getGameTime() % 5 != 0) + return; + List entities = world.getEntities((Entity) null, pipe.getAOE(), entity -> !entity.fireImmune()); + for (Entity entity : entities) + entity.setSecondsOnFire(3); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java index dcad19b59..ba3267b22 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java @@ -5,8 +5,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.BiConsumer; +import java.util.function.Predicate; -import com.simibubi.create.AllTags; +import com.simibubi.create.AllTags.AllFluidTags; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.networking.AllPackets; @@ -212,7 +213,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { } protected boolean canDrainInfinitely(Fluid fluid) { - return maxBlocks() != -1 && !AllTags.AllFluidTags.NO_INFINITE_DRAINING.matches(fluid); + return maxBlocks() != -1 && AllConfigs.SERVER.fluids.bottomlessFluidMode.get().test(fluid); } @Override @@ -238,4 +239,31 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { super.read(nbt, clientPacket); } + public enum BottomlessFluidMode implements Predicate { + ALLOW_ALL { + @Override + public boolean test(Fluid fluid) { + return true; + } + }, + DENY_ALL { + @Override + public boolean test(Fluid fluid) { + return false; + } + }, + ALLOW_BY_TAG { + @Override + public boolean test(Fluid fluid) { + return AllFluidTags.BOTTOMLESS_ALLOW.matches(fluid); + } + }, + DENY_BY_TAG { + @Override + public boolean test(Fluid fluid) { + return !AllFluidTags.BOTTOMLESS_DENY.matches(fluid); + } + }; + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java index 25955db5f..e529c4126 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.particle; +import javax.annotation.Nonnull; + import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.fan.IAirCurrentSource; import com.simibubi.create.content.contraptions.processing.InWorldProcessing; @@ -7,7 +9,11 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.particle.*; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleRenderType; +import net.minecraft.client.particle.SimpleAnimatedParticle; +import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; @@ -17,8 +23,6 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.Vec3; -import javax.annotation.Nonnull; - public class AirFlowParticle extends SimpleAnimatedParticle { private final IAirCurrentSource source; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java index f1e861dae..655694b0d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java @@ -170,14 +170,14 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { FuelType newFuel = FuelType.NONE; int newBurnTime; - if (AllItemTags.BLAZE_BURNER_SPECIAL_FUEL.matches(itemStack)) { + if (AllItemTags.BLAZE_BURNER_FUEL_SPECIAL.matches(itemStack)) { newBurnTime = 1000; newFuel = FuelType.SPECIAL; } else { newBurnTime = ForgeHooks.getBurnTime(itemStack, null); if (newBurnTime > 0) newFuel = FuelType.NORMAL; - else if (AllItemTags.BLAZE_BURNER_REGULAR_FUEL.matches(itemStack)) { + else if (AllItemTags.BLAZE_BURNER_FUEL_REGULAR.matches(itemStack)) { newBurnTime = 1600; // Same as coal newFuel = FuelType.NORMAL; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java index f4d9d4019..e16af7835 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java @@ -26,7 +26,6 @@ import net.minecraft.world.item.crafting.Ingredient.ItemValue; import net.minecraft.world.item.crafting.Ingredient.TagValue; import net.minecraft.world.item.crafting.Ingredient.Value; import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.level.Level; import net.minecraftforge.common.crafting.IShapedRecipe; import net.minecraftforge.common.crafting.MultiItemValue; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 057ea73dd..3ea34a42d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -593,7 +593,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro } protected boolean shouldIgnoreBlockState(BlockState state, BlockEntity te) { - // Block doesnt have a mapping (Water, lava, etc) + // Block doesn't have a mapping (Water, lava, etc) if (state.getBlock() == Blocks.STRUCTURE_VOID) return true; @@ -603,7 +603,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro if (requirement.isInvalid()) return false; - // Block doesnt need to be placed twice (Doors, beds, double plants) + // Block doesn't need to be placed twice (Doors, beds, double plants) if (state.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF) && state.getValue(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.UPPER) return true; diff --git a/src/main/java/com/simibubi/create/foundation/config/CFluids.java b/src/main/java/com/simibubi/create/foundation/config/CFluids.java index 40f98f3b6..7f7d65f61 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CFluids.java +++ b/src/main/java/com/simibubi/create/foundation/config/CFluids.java @@ -1,5 +1,7 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.content.contraptions.fluids.actors.FluidManipulationBehaviour.BottomlessFluidMode; + public class CFluids extends ConfigBase { public final ConfigInt fluidTankCapacity = i(8, 1, "fluidTankCapacity", Comments.buckets, Comments.fluidTankCapacity); @@ -7,10 +9,12 @@ public class CFluids extends ConfigBase { public final ConfigInt mechanicalPumpRange = i(16, 1, "mechanicalPumpRange", Comments.blocks, Comments.mechanicalPumpRange); + public final ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange); public final ConfigInt hosePulleyBlockThreshold = i(10000, -1, "hosePulleyBlockThreshold", Comments.blocks, Comments.toDisable, Comments.hosePulleyBlockThreshold); public final ConfigBool fillInfinite = b(false, "fillInfinite", Comments.fillInfinite); - public final ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange); + public final ConfigEnum bottomlessFluidMode = e(BottomlessFluidMode.ALLOW_BY_TAG, "bottomlessFluidMode", + Comments.bottomlessFluidMode); public ConfigBool placeFluidSourceBlocks = b(true, "placeFluidSourceBlocks", Comments.placeFluidSourceBlocks); @@ -22,17 +26,20 @@ public class CFluids extends ConfigBase { private static class Comments { static String blocks = "[in Blocks]"; static String buckets = "[in Buckets]"; + static String toDisable = "[-1 to disable this behaviour]"; + static String fluidTankCapacity = "The amount of liquid a tank can hold per block."; static String fluidTankMaxHeight = "The maximum height a fluid tank can reach."; static String mechanicalPumpRange = "The maximum distance a mechanical pump can push or pull liquids on either side."; static String hosePulleyRange = "The maximum distance a hose pulley can draw fluid blocks from."; - static String toDisable = "[-1 to disable this behaviour]"; static String hosePulleyBlockThreshold = "The minimum amount of fluid blocks the hose pulley needs to find before deeming it an infinite source."; - static String fillInfinite = "Whether hose pulleys should continue filling up above-threshold sources"; - static String placeFluidSourceBlocks = "Whether open-ended pipes and hose pulleys should be allowed to place fluid sources"; + static String fillInfinite = "Whether hose pulleys should continue filling up above-threshold sources."; + static String bottomlessFluidMode = "Configure which fluids can be drained infinitely."; + + static String placeFluidSourceBlocks = "Whether open-ended pipes and hose pulleys should be allowed to place fluid sources."; } } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java index c6f77e4ad..cf5fb411f 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java @@ -8,6 +8,8 @@ import java.util.function.UnaryOperator; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.lwjgl.glfw.GLFW; + import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.foundation.config.AllConfigs; @@ -144,7 +146,7 @@ public class BaseConfigScreen extends ConfigScreen { super.init(); returnOnClose = true; - TextStencilElement clientText = new TextStencilElement(minecraft.font, new TextComponent(clientTile)).centered(true, true); + TextStencilElement clientText = new TextStencilElement(font, new TextComponent(clientTile)).centered(true, true); addRenderableWidget(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText)); if (clientSpec != null) { @@ -156,7 +158,7 @@ public class BaseConfigScreen extends ConfigScreen { clientText.withElementRenderer(DISABLED_RENDERER); } - TextStencilElement commonText = new TextStencilElement(minecraft.font, new TextComponent(commonTile)).centered(true, true); + TextStencilElement commonText = new TextStencilElement(font, new TextComponent(commonTile)).centered(true, true); addRenderableWidget(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText)); if (commonSpec != null) { @@ -168,7 +170,7 @@ public class BaseConfigScreen extends ConfigScreen { commonText.withElementRenderer(DISABLED_RENDERER); } - TextStencilElement serverText = new TextStencilElement(minecraft.font, new TextComponent(serverTile)).centered(true, true); + TextStencilElement serverText = new TextStencilElement(font, new TextComponent(serverTile)).centered(true, true); addRenderableWidget(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16).showingElement(serverText)); if (serverSpec == null) { @@ -189,7 +191,7 @@ public class BaseConfigScreen extends ConfigScreen { serverText.withElementRenderer(BoxWidget.gradientFactory.apply(serverConfigWidget)); } - TextStencilElement titleText = new TextStencilElement(minecraft.font, modID.toUpperCase(Locale.ROOT)) + TextStencilElement titleText = new TextStencilElement(font, modID.toUpperCase(Locale.ROOT)) .centered(true, true) .withElementRenderer((ms, w, h, alpha) -> { UIRenderHelper.angledGradient(ms, 0, 0, h / 2, h, w / 2, Theme.p(Theme.Key.CONFIG_TITLE_A)); @@ -212,24 +214,23 @@ public class BaseConfigScreen extends ConfigScreen { ConfigScreen.modID = this.modID; goBack = new BoxWidget(width / 2 - 134, height / 2, 20, 20).withPadding(2, 2) - .withCallback(this::onClose); + .withCallback(() -> linkTo(parent)); goBack.showingElement(AllIcons.I_CONFIG_BACK.asStencil() .withElementRenderer(BoxWidget.gradientFactory.apply(goBack))); goBack.getToolTip() .add(new TextComponent("Go Back")); addRenderableWidget(goBack); - TextStencilElement othersText = new TextStencilElement(minecraft.font, new TextComponent("Access Configs of other Mods")).centered(true, true); + TextStencilElement othersText = new TextStencilElement(font, new TextComponent("Access Configs of other Mods")).centered(true, true); others = new BoxWidget(width / 2 - 100, height / 2 - 15 + 90, 200, 16).showingElement(othersText); othersText.withElementRenderer(BoxWidget.gradientFactory.apply(others)); others.withCallback(() -> linkTo(new ConfigModListScreen(this))); addRenderableWidget(others); - } @Override protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { - drawCenteredString(ms, minecraft.font, "Access Configs for Mod:", width / 2, height / 2 - 105, Theme.i(Theme.Key.TEXT_ACCENT_STRONG)); + drawCenteredString(ms, font, "Access Configs for Mod:", width / 2, height / 2 - 105, Theme.i(Theme.Key.TEXT_ACCENT_STRONG)); } private void linkTo(Screen screen) { @@ -238,9 +239,13 @@ public class BaseConfigScreen extends ConfigScreen { } @Override - public void onClose() { - super.onClose(); - ScreenOpener.open(parent); + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (super.keyPressed(keyCode, scanCode, modifiers)) + return true; + if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { + linkTo(parent); + } + return false; } } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java index fc9df4af3..51231e588 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import org.lwjgl.glfw.GLFW; + import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.ScreenOpener; @@ -52,7 +54,7 @@ public class ConfigModListScreen extends ConfigScreen { list.children().addAll(allEntries); goBack = new BoxWidget(width / 2 - listWidth / 2 - 30, height / 2 + 65, 20, 20).withPadding(2, 2) - .withCallback(this::onClose); + .withCallback(() -> ScreenOpener.open(parent)); goBack.showingElement(AllIcons.I_CONFIG_BACK.asStencil() .withElementRenderer(BoxWidget.gradientFactory.apply(goBack))); goBack.getToolTip() @@ -61,16 +63,19 @@ public class ConfigModListScreen extends ConfigScreen { search = new HintableTextFieldWidget(font, width / 2 - listWidth / 2, height - 35, listWidth, 20); search.setResponder(this::updateFilter); - search.setHint("Search.."); + search.setHint("Search..."); search.moveCursorToStart(); addRenderableWidget(search); - } @Override - public void onClose() { - super.onClose(); - ScreenOpener.open(parent); + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (super.keyPressed(keyCode, scanCode, modifiers)) + return true; + if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { + ScreenOpener.open(parent); + } + return false; } private void updateFilter(String search) { diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java index 57f871372..bd86c151d 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java @@ -34,7 +34,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { /* * - * TO DO + * TODO * * reduce number of packets sent to the server when saving a bunch of values * @@ -42,7 +42,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { * * tooltips are hidden underneath the scrollbar, if the bar is near the middle * - * */ + */ public static final Map> backgrounds = new HashMap<>(); public static final PhysicalFloat cogSpin = PhysicalFloat.create().withLimit(10f).withDrag(0.3).addForce(new Force.Static(.2f)); @@ -139,7 +139,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { } float elapsedPartials = minecraft.getDeltaFrameTime(); - CreateMainMenuScreen.panorama.render(elapsedPartials, 1); + CreateMainMenuScreen.PANORAMA.render(elapsedPartials, 1); RenderSystem.setShaderTexture(0, CreateMainMenuScreen.PANORAMA_OVERLAY_TEXTURES); RenderSystem.enableBlend(); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java b/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java index 00c17daaa..71a796e67 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java @@ -29,7 +29,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; public class OpenCreateMenuButton extends Button { - public static ItemStack icon = AllItems.GOGGLES.asStack(); + public static final ItemStack ICON = AllItems.GOGGLES.asStack(); public OpenCreateMenuButton(int x, int y) { super(x, y, 20, 20, TextComponent.EMPTY, OpenCreateMenuButton::click); @@ -40,7 +40,7 @@ public class OpenCreateMenuButton extends Button { super.render(mstack, mouseX, mouseY, pticks); if (!visible) return; - Minecraft.getInstance().getItemRenderer().renderGuiItem(icon, x + 2, y + 2); + Minecraft.getInstance().getItemRenderer().renderGuiItem(ICON, x + 2, y + 2); } public static void click(Button b) { diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java index 53b12052a..d6f58ad2a 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java @@ -127,7 +127,7 @@ public class SubMenuConfigScreen extends ConfigScreen { protected void saveChanges() { UnmodifiableConfig values = spec.getValues(); ConfigHelper.changes.forEach((path, change) -> { - ForgeConfigSpec.ConfigValue configValue = values.get(path); + ForgeConfigSpec.ConfigValue configValue = values.get(path); configValue.set(change.value); if (type == ModConfig.Type.SERVER) { @@ -147,8 +147,8 @@ public class SubMenuConfigScreen extends ConfigScreen { values.valueMap().forEach((key, obj) -> { if (obj instanceof AbstractConfig) { resetConfig((UnmodifiableConfig) obj); - } else if (obj instanceof ForgeConfigSpec.ConfigValue) { - ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue) obj; + } else if (obj instanceof ForgeConfigSpec.ConfigValue) { + ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue) obj; ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw((List) configValue.getPath()); List comments = new ArrayList<>(); @@ -252,7 +252,7 @@ public class SubMenuConfigScreen extends ConfigScreen { search = new ConfigTextField(font, width / 2 - listWidth / 2, height - 35, listWidth, 20); search.setResponder(this::updateFilter); - search.setHint("Search.."); + search.setHint("Search..."); search.moveCursorToStart(); addRenderableWidget(search); @@ -325,7 +325,6 @@ public class SubMenuConfigScreen extends ConfigScreen { .withPadding(2, 2) .showingElement(stencil); - if (!canEdit) { list.children().forEach(e -> e.setEditable(false)); resetAll.active = false; @@ -375,17 +374,17 @@ public class SubMenuConfigScreen extends ConfigScreen { } @Override - public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (super.keyPressed(keyCode, scanCode, modifiers)) return true; if (Screen.hasControlDown()) { - if (code == GLFW.GLFW_KEY_F) { + if (keyCode == GLFW.GLFW_KEY_F) { search.setFocus(true); } } - if (code == GLFW.GLFW_KEY_BACKSPACE) { + if (keyCode == GLFW.GLFW_KEY_BACKSPACE) { attemptBackstep(); } @@ -406,36 +405,31 @@ public class SubMenuConfigScreen extends ConfigScreen { return; } - Consumer action = success -> { + showLeavingPrompt(success -> { if (success == Response.Cancel) return; if (success == Response.Confirm) saveChanges(); ConfigHelper.changes.clear(); ScreenOpener.open(parent); - }; - - showLeavingPrompt(action); + }); } @Override public void onClose() { if (ConfigHelper.changes.isEmpty()) { super.onClose(); - ScreenOpener.open(parent); return; } - Consumer action = success -> { + showLeavingPrompt(success -> { if (success == Response.Cancel) return; if (success == Response.Confirm) saveChanges(); ConfigHelper.changes.clear(); super.onClose(); - }; - - showLeavingPrompt(action); + }); } public void showLeavingPrompt(Consumer action) { diff --git a/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java b/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java index d9f654be1..f1838c470 100644 --- a/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java +++ b/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java @@ -9,9 +9,12 @@ import net.minecraft.world.level.material.PushReaction; @MethodsReturnNonnullByDefault public class SharedProperties { - public static Material beltMaterial = + public static final Material BELT_MATERIAL = new Material(MaterialColor.COLOR_GRAY, false, true, true, true, false, false, PushReaction.NORMAL); + public static final Material CRUSHING_WHEEL_CONTROLLER_MATERIAL = + new Material(MaterialColor.NONE, false, false, true, true, false, false, PushReaction.BLOCK); + public static Block stone() { return Blocks.ANDESITE; } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java b/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java index cf8fb24f1..0058a8eb5 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java @@ -16,8 +16,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.simibubi.create.AllRecipeTypes; -import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; - import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.SetTag; diff --git a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java index a670c3e4d..c700faf2b 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java @@ -112,6 +112,21 @@ public abstract class AbstractSimiScreen extends Screen { ms.popPose(); } + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + boolean keyPressed = super.keyPressed(keyCode, scanCode, modifiers); + if (keyPressed || getFocused() != null) + return keyPressed; + + InputConstants.Key mouseKey = InputConstants.getKey(keyCode, scanCode); + if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { + this.onClose(); + return true; + } + + return false; + } + protected void prepareFrame() { } @@ -138,20 +153,5 @@ public abstract class AbstractSimiScreen extends Screen { protected void debugWindowArea(PoseStack matrixStack) { fill(matrixStack, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3); } - - @Override - public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { - boolean keyPressed = super.keyPressed(pKeyCode, pScanCode, pModifiers); - if (keyPressed || getFocused() != null) - return keyPressed; - - InputConstants.Key mouseKey = InputConstants.getKey(pKeyCode, pScanCode); - if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { - this.onClose(); - return true; - } - - return false; - } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java index 2a4ecc98e..211539583 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java @@ -99,8 +99,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { @Override public void tick() { super.tick(); - confirm.tick(); - cancel.tick(); + source.tick(); } @Override @@ -109,9 +108,9 @@ public class ConfirmationScreen extends AbstractSimiScreen { ArrayList copy = new ArrayList<>(text); text.clear(); - copy.forEach(t -> text.addAll(minecraft.font.getSplitter().splitLines(t, 300, Style.EMPTY))); + copy.forEach(t -> text.addAll(font.getSplitter().splitLines(t, 300, Style.EMPTY))); - textHeight = text.size() * (minecraft.font.lineHeight + 1) + 4; + textHeight = text.size() * (font.lineHeight + 1) + 4; textWidth = 300; if (centered) { @@ -133,7 +132,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { int buttonX = x + textWidth / 2 - 6 - (int) (70 * (tristate ? 1.5f : 1)); TextStencilElement confirmText = - new TextStencilElement(minecraft.font, tristate ? "Save" : "Confirm").centered(true, true); + new TextStencilElement(font, tristate ? "Save" : "Confirm").centered(true, true); confirm = new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.Confirm)); confirm.showingElement(confirmText.withElementRenderer(BoxWidget.gradientFactory.apply(confirm))); addRenderableWidget(confirm); @@ -142,7 +141,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { if (tristate) { TextStencilElement confirmDontSaveText = - new TextStencilElement(minecraft.font, "Don't Save").centered(true, true); + new TextStencilElement(font, "Don't Save").centered(true, true); confirmDontSave = new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.ConfirmDontSave)); confirmDontSave.showingElement( @@ -151,7 +150,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { buttonX += 12 + 70; } - TextStencilElement cancelText = new TextStencilElement(minecraft.font, "Cancel").centered(true, true); + TextStencilElement cancelText = new TextStencilElement(font, "Cancel").centered(true, true); cancel = new BoxWidget(buttonX, y + textHeight + 6, 70, 16) .withCallback(() -> accept(Response.Cancel)); cancel.showingElement(cancelText.withElementRenderer(BoxWidget.gradientFactory.apply(cancel))); @@ -162,6 +161,8 @@ public class ConfirmationScreen extends AbstractSimiScreen { .withBounds(width + 10, textHeight + 35) .at(-5, y - 5); + if (text.size() == 1) + x = (width - font.width(text.get(0))) / 2; } @Override @@ -176,26 +177,21 @@ public class ConfirmationScreen extends AbstractSimiScreen { @Override protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { - textBackground.render(ms); - int offset = minecraft.font.lineHeight + 1; + int offset = font.lineHeight + 1; int lineY = y - offset; ms.pushPose(); ms.translate(0, 0, 200); for (FormattedText line : text) { - lineY = lineY + offset; + lineY += offset; if (line == null) continue; - int textX = x; - if (text.size() == 1) - x = (width - minecraft.font.width(line)) / 2; - minecraft.font.draw(ms, line.getString(), textX, lineY, 0xeaeaea); + font.draw(ms, line.getString(), x, lineY, 0xeaeaea); } ms.popPose(); - } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/CreateMainMenuScreen.java b/src/main/java/com/simibubi/create/foundation/gui/CreateMainMenuScreen.java index 5b1d96d66..f4937eedb 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/CreateMainMenuScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/CreateMainMenuScreen.java @@ -30,14 +30,18 @@ import net.minecraftforge.fml.util.ObfuscationReflectionHelper; public class CreateMainMenuScreen extends AbstractSimiScreen { - protected final Screen parent; - protected boolean returnOnClose; - public static final CubeMap PANORAMA_RESOURCES = new CubeMap(Create.asResource("textures/gui/title/background/panorama")); public static final ResourceLocation PANORAMA_OVERLAY_TEXTURES = new ResourceLocation("textures/gui/title/background/panorama_overlay.png"); - public static PanoramaRenderer panorama = new PanoramaRenderer(PANORAMA_RESOURCES); + public static final PanoramaRenderer PANORAMA = new PanoramaRenderer(PANORAMA_RESOURCES); + + public static final String PROJECT_LINK = "https://www.curseforge.com/minecraft/mc-mods/create"; + public static final String ISSUE_TRACKER_LINK = "https://github.com/Creators-of-Create/Create/issues"; + public static final String SUPPORT_LINK = "https://github.com/Creators-of-Create/Create/wiki/Supporting-the-Project"; + + protected final Screen parent; + protected boolean returnOnClose; private PanoramaRenderer vanillaPanorama; private long firstRenderTime; @@ -69,7 +73,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { if (parent instanceof TitleScreen) { if (alpha < 1) vanillaPanorama.render(elapsedPartials, 1); - panorama.render(elapsedPartials, alpha); + PANORAMA.render(elapsedPartials, alpha); RenderSystem.setShaderTexture(0, PANORAMA_OVERLAY_TEXTURES); RenderSystem.enableBlend(); @@ -115,7 +119,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { drawCenteredString(ms, font, new TextComponent(Create.NAME).withStyle(ChatFormatting.BOLD) .append( new TextComponent(" v" + Create.VERSION).withStyle(ChatFormatting.BOLD, ChatFormatting.WHITE)), - width / 2, 89, 0xff_E4BB67); + width / 2, 89, 0xFF_E4BB67); ms.popPose(); RenderSystem.disableDepthTest(); @@ -128,14 +132,14 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { } private void addButtons() { - int yStart = height / 4 + (parent instanceof TitleScreen ? 40 : 40); + int yStart = height / 4 + 40; int center = width / 2; int bHeight = 20; int bShortWidth = 98; int bLongWidth = 200; addRenderableWidget( - new Button(center - 100, yStart + 92, bLongWidth, bHeight, Lang.translate("menu.return"), $ -> onClose())); + new Button(center - 100, yStart + 92, bLongWidth, bHeight, Lang.translate("menu.return"), $ -> linkTo(parent))); addRenderableWidget(new Button(center - 100, yStart + 24 + -16, bLongWidth, bHeight, Lang.translate("menu.configure"), $ -> linkTo(BaseConfigScreen.forCreate(this)))); @@ -144,16 +148,12 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { gettingStarted.active = !(parent instanceof TitleScreen); addRenderableWidget(gettingStarted); - String projectLink = "https://www.curseforge.com/minecraft/mc-mods/create"; - String issueTrackerLink = "https://github.com/Creators-of-Create/Create/issues"; - String supportLink = "https://github.com/Creators-of-Create/Create/wiki/Supporting-the-Project"; - addRenderableWidget(new Button(center - 100, yStart + 48 + -16, bShortWidth, bHeight, Lang.translate("menu.project_page"), - $ -> linkTo(projectLink))); + $ -> linkTo(PROJECT_LINK))); addRenderableWidget(new Button(center + 2, yStart + 68, bShortWidth, bHeight, Lang.translate("menu.report_bugs"), - $ -> linkTo(issueTrackerLink))); + $ -> linkTo(ISSUE_TRACKER_LINK))); addRenderableWidget(new Button(center - 100, yStart + 68, bShortWidth, bHeight, Lang.translate("menu.support"), - $ -> linkTo(supportLink))); + $ -> linkTo(SUPPORT_LINK))); } @Override @@ -171,10 +171,6 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { } } - public void tick() { - super.tick(); - } - private void linkTo(Screen screen) { returnOnClose = false; ScreenOpener.open(screen); @@ -195,10 +191,4 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { return true; } - @Override - public void onClose() { - super.onClose(); - ScreenOpener.open(parent); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/gui/Theme.java b/src/main/java/com/simibubi/create/foundation/gui/Theme.java index 01bbb8c98..665b3da50 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/Theme.java +++ b/src/main/java/com/simibubi/create/foundation/gui/Theme.java @@ -16,7 +16,7 @@ import com.simibubi.create.foundation.utility.Couple; public class Theme { private static final List THEMES = new ArrayList<>(); - private static final Theme BASE = addTheme(new Theme()); + public static final Theme BASE = addTheme(new Theme()); public static Theme addTheme(@Nonnull Theme theme) { THEMES.add(theme); @@ -39,7 +39,7 @@ public class Theme { .filter(Objects::nonNull) .findFirst() .map(holder -> holder.lookupKey == null ? holder : resolve(holder.lookupKey)) - .orElse(ColorHolder.missing); + .orElse(ColorHolder.MISSING); } @Nonnull public static Couple p(@Nonnull Key key) {return p(key.get());} @@ -144,40 +144,40 @@ public class Theme { public static class Key { - public static Key BUTTON_IDLE = new Key(); - public static Key BUTTON_HOVER = new Key(); - public static Key BUTTON_CLICK = new Key(); - public static Key BUTTON_DISABLE = new Key(); - public static Key BUTTON_SUCCESS = new Key(); - public static Key BUTTON_FAIL = new Key(); + public static final Key BUTTON_IDLE = new Key(); + public static final Key BUTTON_HOVER = new Key(); + public static final Key BUTTON_CLICK = new Key(); + public static final Key BUTTON_DISABLE = new Key(); + public static final Key BUTTON_SUCCESS = new Key(); + public static final Key BUTTON_FAIL = new Key(); - public static Key TEXT = new Key(); - public static Key TEXT_DARKER = new Key(); - public static Key TEXT_ACCENT_STRONG = new Key(); - public static Key TEXT_ACCENT_SLIGHT = new Key(); + public static final Key TEXT = new Key(); + public static final Key TEXT_DARKER = new Key(); + public static final Key TEXT_ACCENT_STRONG = new Key(); + public static final Key TEXT_ACCENT_SLIGHT = new Key(); - public static Key STREAK = new Key(); - public static Key VANILLA_TOOLTIP_BORDER = new Key(); - public static Key VANILLA_TOOLTIP_BACKGROUND = new Key(); + public static final Key STREAK = new Key(); + public static final Key VANILLA_TOOLTIP_BORDER = new Key(); + public static final Key VANILLA_TOOLTIP_BACKGROUND = new Key(); - public static Key PONDER_BACKGROUND_TRANSPARENT = new Key(); - public static Key PONDER_BACKGROUND_FLAT = new Key(); - public static Key PONDER_IDLE = new Key(); - public static Key PONDER_HOVER = new Key(); - public static Key PONDER_HIGHLIGHT = new Key(); - public static Key TEXT_WINDOW_BORDER = new Key(); - public static Key PONDER_BACK_ARROW = new Key(); - public static Key PONDER_PROGRESSBAR = new Key(); - public static Key PONDER_MISSING_CREATE = new Key(); - public static Key PONDER_MISSING_VANILLA = new Key(); + public static final Key PONDER_BACKGROUND_TRANSPARENT = new Key(); + public static final Key PONDER_BACKGROUND_FLAT = new Key(); + public static final Key PONDER_IDLE = new Key(); + public static final Key PONDER_HOVER = new Key(); + public static final Key PONDER_HIGHLIGHT = new Key(); + public static final Key TEXT_WINDOW_BORDER = new Key(); + public static final Key PONDER_BACK_ARROW = new Key(); + public static final Key PONDER_PROGRESSBAR = new Key(); + public static final Key PONDER_MISSING_CREATE = new Key(); + public static final Key PONDER_MISSING_VANILLA = new Key(); - public static Key PONDER_BUTTON_IDLE = new Key(); - public static Key PONDER_BUTTON_HOVER = new Key(); - public static Key PONDER_BUTTON_CLICK = new Key(); - public static Key PONDER_BUTTON_DISABLE = new Key(); + public static final Key PONDER_BUTTON_IDLE = new Key(); + public static final Key PONDER_BUTTON_HOVER = new Key(); + public static final Key PONDER_BUTTON_CLICK = new Key(); + public static final Key PONDER_BUTTON_DISABLE = new Key(); - public static Key CONFIG_TITLE_A = new Key(); - public static Key CONFIG_TITLE_B = new Key(); + public static final Key CONFIG_TITLE_A = new Key(); + public static final Key CONFIG_TITLE_B = new Key(); private static int index = 0; @@ -198,7 +198,7 @@ public class Theme { private static class ColorHolder { - private static final ColorHolder missing = ColorHolder.single(Color.BLACK); + private static final ColorHolder MISSING = ColorHolder.single(Color.BLACK); private Couple colors; private String lookupKey; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java index fd5b20018..6da53b0fc 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java @@ -30,7 +30,7 @@ import net.minecraftforge.items.ItemHandlerHelper; */ public class DirectBeltInputBehaviour extends TileEntityBehaviour { - public static BehaviourType TYPE = new BehaviourType<>(); + public static final BehaviourType TYPE = new BehaviourType<>(); private InsertionCallback tryInsert; private AvailabilityPredicate canInsert; diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java index cd6087707..1f7cbc500 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java @@ -1,22 +1,13 @@ package com.simibubi.create.foundation.utility.ghost; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; import java.util.List; import java.util.Random; import javax.annotation.Nullable; -import org.lwjgl.system.MemoryStack; - import com.jozufozu.flywheel.core.virtual.VirtualEmptyModelData; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.placement.PlacementHelpers; @@ -31,28 +22,29 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Vec3i; import net.minecraft.util.Mth; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.model.data.IModelData; public abstract class GhostBlockRenderer { - private static final GhostBlockRenderer transparent = new TransparentGhostBlockRenderer(); - - public static GhostBlockRenderer transparent() { - return transparent; - } - - private static final GhostBlockRenderer standard = new DefaultGhostBlockRenderer(); + private static final GhostBlockRenderer STANDARD = new DefaultGhostBlockRenderer(); public static GhostBlockRenderer standard() { - return standard; + return STANDARD; + } + + private static final GhostBlockRenderer TRANSPARENT = new TransparentGhostBlockRenderer(); + + public static GhostBlockRenderer transparent() { + return TRANSPARENT; } public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params); private static class DefaultGhostBlockRenderer extends GhostBlockRenderer { + @Override public void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { ms.pushPose(); @@ -78,19 +70,15 @@ public abstract class GhostBlockRenderer { private static class TransparentGhostBlockRenderer extends GhostBlockRenderer { + @Override public void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { - - // prepare ms.pushPose(); - // RenderSystem.pushMatrix(); - Minecraft mc = Minecraft.getInstance(); BlockRenderDispatcher dispatcher = mc.getBlockRenderer(); BakedModel model = dispatcher.getBlockModel(params.state); - // RenderType layer = RenderTypeLookup.getEntityBlockLayer(params.state); RenderType layer = RenderType.translucent(); VertexConsumer vb = buffer.getEarlyBuffer(layer); @@ -101,104 +89,54 @@ public abstract class GhostBlockRenderer { ms.scale(.85f, .85f, .85f); ms.translate(-.5, -.5, -.5); - // dispatcher.getBlockModelRenderer().renderModel(ms.peek(), vb, params.state, model, 1f, 1f, 1f, LightTexture.FULL_BRIGHT, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); - renderModel(params, ms.last(), vb, params.state, model, 1f, 1f, 1f, + float alpha = params.alphaSupplier.get() * .75f * PlacementHelpers.getCurrentAlpha(); + renderModel(ms.last(), vb, params.state, model, 1f, 1f, 1f, alpha, LevelRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); - // buffer.draw(); - // clean - // RenderSystem.popMatrix(); ms.popPose(); - } - // BlockModelRenderer - public void renderModel(GhostBlockParams params, PoseStack.Pose entry, VertexConsumer vb, - @Nullable BlockState state, BakedModel model, float p_228804_5_, float p_228804_6_, float p_228804_7_, - int p_228804_8_, int p_228804_9_, net.minecraftforge.client.model.data.IModelData modelData) { + // ModelBlockRenderer + public void renderModel(PoseStack.Pose pose, VertexConsumer consumer, + @Nullable BlockState state, BakedModel model, float red, float green, float blue, + float alpha, int packedLight, int packedOverlay, IModelData modelData) { Random random = new Random(); for (Direction direction : Direction.values()) { random.setSeed(42L); - renderQuad(params, entry, vb, p_228804_5_, p_228804_6_, p_228804_7_, - model.getQuads(state, direction, random, modelData), p_228804_8_, p_228804_9_); + renderQuadList(pose, consumer, red, green, blue, alpha, + model.getQuads(state, direction, random, modelData), packedLight, packedOverlay); } random.setSeed(42L); - renderQuad(params, entry, vb, p_228804_5_, p_228804_6_, p_228804_7_, - model.getQuads(state, (Direction) null, random, modelData), p_228804_8_, p_228804_9_); + renderQuadList(pose, consumer, red, green, blue, alpha, + model.getQuads(state, null, random, modelData), packedLight, packedOverlay); } - // BlockModelRenderer - private static void renderQuad(GhostBlockParams params, PoseStack.Pose p_228803_0_, - VertexConsumer p_228803_1_, float p_228803_2_, float p_228803_3_, float p_228803_4_, - List p_228803_5_, int p_228803_6_, int p_228803_7_) { - Float alpha = params.alphaSupplier.get() * .75f * PlacementHelpers.getCurrentAlpha(); - - for (BakedQuad bakedquad : p_228803_5_) { + // ModelBlockRenderer + private static void renderQuadList(PoseStack.Pose pose, VertexConsumer consumer, + float red, float green, float blue, float alpha, List quads, + int packedLight, int packedOverlay) { + for (BakedQuad quad : quads) { float f; float f1; float f2; - if (bakedquad.isTinted()) { - f = Mth.clamp(p_228803_2_, 0.0F, 1.0F); - f1 = Mth.clamp(p_228803_3_, 0.0F, 1.0F); - f2 = Mth.clamp(p_228803_4_, 0.0F, 1.0F); + if (quad.isTinted()) { + f = Mth.clamp(red, 0.0F, 1.0F); + f1 = Mth.clamp(green, 0.0F, 1.0F); + f2 = Mth.clamp(blue, 0.0F, 1.0F); } else { f = 1.0F; f1 = 1.0F; f2 = 1.0F; } - quad(alpha, p_228803_1_, p_228803_0_, bakedquad, new float[] { 1f, 1f, 1f, 1f }, f, f1, f2, - new int[] { p_228803_6_, p_228803_6_, p_228803_6_, p_228803_6_ }, p_228803_7_); + consumer.putBulkData(pose, quad, f, f1, f2, alpha, packedLight, packedOverlay); } } - // IVertexBuilder - static void quad(float alpha, VertexConsumer vb, PoseStack.Pose p_227890_1_, BakedQuad p_227890_2_, - float[] p_227890_3_, float p_227890_4_, float p_227890_5_, float p_227890_6_, int[] p_227890_7_, - int p_227890_8_) { - int[] aint = p_227890_2_.getVertices(); - Vec3i Vector3i = p_227890_2_.getDirection() - .getNormal(); - Vector3f vector3f = new Vector3f((float) Vector3i.getX(), (float) Vector3i.getY(), (float) Vector3i.getZ()); - Matrix4f matrix4f = p_227890_1_.pose(); - vector3f.transform(p_227890_1_.normal()); - int vertexSize = DefaultVertexFormat.BLOCK.getIntegerSize(); - int j = aint.length / vertexSize; - - try (MemoryStack memorystack = MemoryStack.stackPush()) { - ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize()); - IntBuffer intbuffer = bytebuffer.asIntBuffer(); - - for (int k = 0; k < j; ++k) { - ((Buffer) intbuffer).clear(); - intbuffer.put(aint, k * vertexSize, vertexSize); - float f = bytebuffer.getFloat(0); - float f1 = bytebuffer.getFloat(4); - float f2 = bytebuffer.getFloat(8); - float r; - float g; - float b; - - r = p_227890_3_[k] * p_227890_4_; - g = p_227890_3_[k] * p_227890_5_; - b = p_227890_3_[k] * p_227890_6_; - - int l = vb.applyBakedLighting(p_227890_7_[k], bytebuffer); - float f9 = bytebuffer.getFloat(16); - float f10 = bytebuffer.getFloat(20); - Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F); - vector4f.transform(matrix4f); - vb.applyBakedNormals(vector3f, bytebuffer, p_227890_1_.normal()); - vb.vertex(vector4f.x(), vector4f.y(), vector4f.z(), r, g, b, alpha, f9, f10, p_227890_8_, - l, vector3f.x(), vector3f.y(), vector3f.z()); - } - } - } - } }