diff --git a/src/generated/resources/assets/frostedheart/lang/en_ud.json b/src/generated/resources/assets/frostedheart/lang/en_ud.json index 12f682d40..af333dca1 100644 --- a/src/generated/resources/assets/frostedheart/lang/en_ud.json +++ b/src/generated/resources/assets/frostedheart/lang/en_ud.json @@ -6,6 +6,8 @@ "block.frostedheart.besnowed_debris_block": "ʞɔoןᗺ sıɹqǝᗡ pǝʍousǝᗺ", "block.frostedheart.besnowed_twigs": "sbıʍ⟘ pǝʍousǝᗺ", "block.frostedheart.besnowed_twigs_block": "ʞɔoןᗺ sbıʍ⟘ pǝʍousǝᗺ", + "block.frostedheart.biogas_digester_controller": "ɹǝןןoɹʇuoƆ ɹǝʇsǝbıᗡ sɐboıᗺ", + "block.frostedheart.biogas_digester_io": "ʇndʇnO & ʇnduI ɹǝʇsǝbıᗡ sɐboıᗺ", "block.frostedheart.blood_block": "pooןᗺ", "block.frostedheart.bone_block": "sǝuoᗺ ɟo ǝןıԀ", "block.frostedheart.broken_plate": "buıʇɐןԀ ɹoʇɐɹǝuǝ⅁ uǝʞoɹᗺ", diff --git a/src/generated/resources/assets/frostedheart/lang/en_us.json b/src/generated/resources/assets/frostedheart/lang/en_us.json index f748fc3c3..f46b64bbf 100644 --- a/src/generated/resources/assets/frostedheart/lang/en_us.json +++ b/src/generated/resources/assets/frostedheart/lang/en_us.json @@ -6,6 +6,8 @@ "block.frostedheart.besnowed_debris_block": "Besnowed Debris Block", "block.frostedheart.besnowed_twigs": "Besnowed Twigs", "block.frostedheart.besnowed_twigs_block": "Besnowed Twigs Block", + "block.frostedheart.biogas_digester_controller": "Biogas Digester Controller", + "block.frostedheart.biogas_digester_io": "Biogas Digester Input & Output", "block.frostedheart.blood_block": "Blood", "block.frostedheart.bone_block": "Pile of Bones", "block.frostedheart.broken_plate": "Broken Generator Plating", diff --git a/src/generated/resources/assets/frostedheart/models/item/biogas_digester_controller.json b/src/generated/resources/assets/frostedheart/models/item/biogas_digester_controller.json new file mode 100644 index 000000000..c393cba1c --- /dev/null +++ b/src/generated/resources/assets/frostedheart/models/item/biogas_digester_controller.json @@ -0,0 +1,3 @@ +{ + "parent": "frostedheart:block/biogas_digester_controller" +} \ No newline at end of file diff --git a/src/generated/resources/assets/frostedheart/models/item/biogas_digester_io.json b/src/generated/resources/assets/frostedheart/models/item/biogas_digester_io.json new file mode 100644 index 000000000..9587dd40e --- /dev/null +++ b/src/generated/resources/assets/frostedheart/models/item/biogas_digester_io.json @@ -0,0 +1,3 @@ +{ + "parent": "frostedheart:block/biogas_digester_io" +} \ No newline at end of file diff --git a/src/generated/resources/data/frostedheart/loot_tables/blocks/biogas_digester_controller.json b/src/generated/resources/data/frostedheart/loot_tables/blocks/biogas_digester_controller.json new file mode 100644 index 000000000..c1af79a78 --- /dev/null +++ b/src/generated/resources/data/frostedheart/loot_tables/blocks/biogas_digester_controller.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "frostedheart:biogas_digester_controller" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "frostedheart:blocks/biogas_digester_controller" +} \ No newline at end of file diff --git a/src/generated/resources/data/frostedheart/loot_tables/blocks/biogas_digester_io.json b/src/generated/resources/data/frostedheart/loot_tables/blocks/biogas_digester_io.json new file mode 100644 index 000000000..9389792fc --- /dev/null +++ b/src/generated/resources/data/frostedheart/loot_tables/blocks/biogas_digester_io.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "frostedheart:biogas_digester_io" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "frostedheart:blocks/biogas_digester_io" +} \ No newline at end of file diff --git a/src/generated/resources/data/frostedheart/tags/blocks/machines/metal.json b/src/generated/resources/data/frostedheart/tags/blocks/machines/metal.json index 3c8076f15..5be1ca222 100644 --- a/src/generated/resources/data/frostedheart/tags/blocks/machines/metal.json +++ b/src/generated/resources/data/frostedheart/tags/blocks/machines/metal.json @@ -15,6 +15,8 @@ "frostedheart:requester_chest", "frostedheart:storage_chest", "frostedheart:supplier_chest", - "frostedheart:test_logistic_core" + "frostedheart:test_logistic_core", + "frostedheart:biogas_digester_controller", + "frostedheart:biogas_digester_io" ] } \ No newline at end of file diff --git a/src/generated/resources/data/frostedheart/tags/blocks/machines/wooden.json b/src/generated/resources/data/frostedheart/tags/blocks/machines/wooden.json index 4e0bea540..50c1ae6a3 100644 --- a/src/generated/resources/data/frostedheart/tags/blocks/machines/wooden.json +++ b/src/generated/resources/data/frostedheart/tags/blocks/machines/wooden.json @@ -2,6 +2,7 @@ "values": [ "frostedheart:incubator", "frostedheart:heat_pipe", - "frostedheart:wardrobe" + "frostedheart:wardrobe", + "frostedheart:gunpowder_barrel" ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index 5d6d895d8..69f7692d6 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -56,6 +56,8 @@ "frostedheart:ruined_machine_screen", "frostedheart:ruined_machine_screen_cracked", "frostedheart:ruined_machine_switch", + "frostedheart:biogas_digester_controller", + "frostedheart:biogas_digester_io", "#frostedheart:machines/metal", "#frostedheart:permafrost", "frostedheart:generator_t1", diff --git a/src/generated/resources/data/minecraft/tags/blocks/needs_stone_tool.json b/src/generated/resources/data/minecraft/tags/blocks/needs_stone_tool.json index fca83e545..84517624c 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/needs_stone_tool.json +++ b/src/generated/resources/data/minecraft/tags/blocks/needs_stone_tool.json @@ -19,6 +19,8 @@ "frostedheart:generator_amplifier_r1", "frostedheart:refractory_bricks", "frostedheart:high_refractory_bricks", + "frostedheart:biogas_digester_controller", + "frostedheart:biogas_digester_io", "#frostedheart:permafrost" ] } \ No newline at end of file diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHScreens.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHScreens.java index 3ba8b730f..c55efa2c2 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHScreens.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHScreens.java @@ -24,6 +24,9 @@ import com.teammoeg.chorda.client.cui.CUIMenuScreen; import com.teammoeg.chorda.client.cui.PrimaryLayer; import com.teammoeg.frostedheart.bootstrap.common.FHMenuTypes; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterControllerMenu; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterControllerScreen; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterIOScreen; import com.teammoeg.frostedheart.content.climate.block.ClothesScreen; import com.teammoeg.frostedheart.content.climate.block.generator.GeneratorScreen; import com.teammoeg.frostedheart.content.climate.block.generator.t1.T1GeneratorLogic; @@ -64,6 +67,9 @@ public static void init() { MenuScreens.register(FHMenuTypes.SUPPLY_CHEST.get(), LogisticChestScreen::new); MenuScreens.register(FHMenuTypes.STORAGE_CHEST.get(), LogisticChestScreen::new); MenuScreens.register(FHMenuTypes.REQUEST_CHEST.get(), LogisticChestScreen::new); + MenuScreens.register(FHMenuTypes.BIOGAS_DIGESTER_CONTROLLER.get(), BiogasDigesterControllerScreen::new); + MenuScreens.register(FHMenuTypes.BIOGAS_DIGESTER_IO.get(), BiogasDigesterIOScreen::new); + } public static void diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHTabs.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHTabs.java index 20d4a92cd..1843d774a 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHTabs.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/client/FHTabs.java @@ -23,6 +23,7 @@ import com.teammoeg.frostedheart.FHMain; import com.teammoeg.chorda.creativeTab.ICreativeModeTabItem; import com.teammoeg.chorda.creativeTab.TabType; +import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; import com.teammoeg.frostedheart.bootstrap.common.FHItems; import com.teammoeg.frostedheart.infrastructure.gen.FHRegistrate; @@ -35,11 +36,15 @@ import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.RegistryObject; import org.apache.commons.lang3.mutable.MutableObject; @@ -50,7 +55,7 @@ import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; - +@Mod.EventBusSubscriber(modid = FHMain.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class FHTabs { public static final DeferredRegister TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, FHMain.MODID); @@ -120,6 +125,22 @@ public class FHTabs { .build()); public static final TabType itemGroup = new TabType(MISC); + @SubscribeEvent + public static void onBuildCreativeTabContents(BuildCreativeModeTabContentsEvent event) { + if (event.getTab() == TOOLS.get()){ + Item item = Item.byBlock(FHBlocks.GUNPOWDER_BARREL.get()); + for (int i = 1; i <= 3; i++) { + for (int j = 0; j <= 3; j++){ + ItemStack stack = new ItemStack(item); + CompoundTag nbt = new CompoundTag(); + nbt.putInt("Power", i); + nbt.putInt("Fortune", j); + BlockItem.setBlockEntityData(stack, FHBlockEntityTypes.GUNPOWDER_BARREL.get(),nbt); + event.accept(stack); + } + } + } + } public static void fillFHTab(CreativeModeTab.ItemDisplayParameters parms, CreativeModeTab.Output out) { for (final RegistryObject itemRef : FHItems.ITEMS.getEntries()) { diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlockEntityTypes.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlockEntityTypes.java index 088978b5f..ab364fb3b 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlockEntityTypes.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlockEntityTypes.java @@ -19,16 +19,11 @@ package com.teammoeg.frostedheart.bootstrap.common; -import static com.teammoeg.frostedheart.FHMain.*; - -import java.util.Arrays; -import java.util.Collection; -import java.util.function.Supplier; -import java.util.stream.Collectors; - import com.google.common.collect.ImmutableSet; import com.simibubi.create.content.kinetics.base.HalfShaftInstance; import com.teammoeg.frostedheart.FHMain; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterControllerBlockEntity; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterIOBlockEntity; import com.teammoeg.frostedheart.content.climate.block.wardrobe.WardrobeBlockEntity; import com.teammoeg.frostedheart.content.decoration.RelicChestTileEntity; import com.teammoeg.frostedheart.content.incubator.HeatIncubatorTileEntity; @@ -51,10 +46,10 @@ import com.teammoeg.frostedheart.content.town.mine.MineBaseBlockEntity; import com.teammoeg.frostedheart.content.town.mine.MineBlockEntity; import com.teammoeg.frostedheart.content.town.warehouse.WarehouseBlockEntity; +import com.teammoeg.frostedheart.content.utility.gunpowder_barrel.GunpowderBarrelBlockEntity; import com.teammoeg.frostedheart.content.utility.incinerator.GasVentTileEntity; import com.teammoeg.frostedheart.content.utility.incinerator.OilBurnerTileEntity; import com.tterrag.registrate.util.entry.BlockEntityEntry; - import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -63,6 +58,13 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.Arrays; +import java.util.Collection; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import static com.teammoeg.frostedheart.FHMain.REGISTRATE; + public class FHBlockEntityTypes { public static final BlockEntityEntry CREATIVE_HEATER = REGISTRATE .blockEntity("creative_heater", CreativeHeaterBlockEntity::new) @@ -151,6 +153,13 @@ public class FHBlockEntityTypes { "supplier_chest", makeType(SupplierTileEntity::new, FHBlocks.SUPPLIER_CHEST::get) ); public static final RegistryObject> NETWORK_CORE = REGISTER.register( "logistic_test_core", makeType(NetworkCoreTileEntity::new, FHBlocks.TEST_LOGISTIC_CORE::get)); + public static final RegistryObject> BIOGAS_DIGESTER_CONTROLLER = REGISTER.register( + "biogas_digest_controller", makeType(BiogasDigesterControllerBlockEntity::new, FHBlocks.BIOGAS_DIGESTER_CONTROLLER::get)); + public static final RegistryObject> BIOGAS_DIGESTER_IO = REGISTER.register( + "biogas_digest_io", makeType(BiogasDigesterIOBlockEntity::new, FHBlocks.BIOGAS_DIGESTER_IO::get)); + public static final RegistryObject> GUNPOWDER_BARREL = REGISTER.register( + "gunpowder_barrel", makeType(GunpowderBarrelBlockEntity::new, FHBlocks.GUNPOWDER_BARREL::get)); + private static Supplier> makeType(BlockEntitySupplier create, Supplier valid) { return makeTypeMultipleBlocks(create, () -> ImmutableSet.of(valid.get())); } diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlocks.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlocks.java index 5350ec398..f351b6d1c 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlocks.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHBlocks.java @@ -19,16 +19,6 @@ package com.teammoeg.frostedheart.bootstrap.common; -import static com.teammoeg.frostedheart.FHMain.*; -import static com.teammoeg.frostedheart.infrastructure.gen.FHBlockStateGen.*; -import static com.teammoeg.frostedheart.infrastructure.gen.FHTagGen.*; -import static net.minecraft.world.level.block.Blocks.*; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; - import com.google.common.collect.ImmutableMap; import com.simibubi.create.AllTags; import com.simibubi.create.foundation.data.AssetLookup; @@ -37,19 +27,21 @@ import com.teammoeg.chorda.block.CDirectionalFacingBlock; import com.teammoeg.chorda.block.CDirectionalRotatableBlock; import com.teammoeg.frostedheart.FHMain; +import com.teammoeg.frostedheart.bootstrap.client.FHTabs; import com.teammoeg.frostedheart.bootstrap.reference.FHFoodProperties; +import com.teammoeg.frostedheart.bootstrap.reference.FHProps; +import com.teammoeg.frostedheart.bootstrap.reference.FHTags; import com.teammoeg.frostedheart.content.agriculture.RubberDandelionBlock; +import com.teammoeg.frostedheart.content.agriculture.RyeBlock; +import com.teammoeg.frostedheart.content.agriculture.WhiteTurnipBlock; import com.teammoeg.frostedheart.content.agriculture.WildRubberDandelionBlock; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterControllerBlock; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterIOBlock; import com.teammoeg.frostedheart.content.climate.block.CooledMagmaBlock; import com.teammoeg.frostedheart.content.climate.block.LayeredThinIceBlock; import com.teammoeg.frostedheart.content.climate.block.ThinIceBlock; -import com.teammoeg.frostedheart.content.decoration.*; -import com.teammoeg.frostedheart.bootstrap.client.FHTabs; -import com.teammoeg.frostedheart.bootstrap.reference.FHProps; -import com.teammoeg.frostedheart.bootstrap.reference.FHTags; -import com.teammoeg.frostedheart.content.agriculture.RyeBlock; -import com.teammoeg.frostedheart.content.agriculture.WhiteTurnipBlock; import com.teammoeg.frostedheart.content.climate.block.wardrobe.WardrobeBlock; +import com.teammoeg.frostedheart.content.decoration.*; import com.teammoeg.frostedheart.content.incubator.HeatIncubatorBlock; import com.teammoeg.frostedheart.content.incubator.IncubatorBlock; import com.teammoeg.frostedheart.content.robotics.logistics.LogisticChestBlock; @@ -72,6 +64,8 @@ import com.teammoeg.frostedheart.content.town.mine.MineBaseBlock; import com.teammoeg.frostedheart.content.town.mine.MineBlock; import com.teammoeg.frostedheart.content.town.warehouse.WarehouseBlock; +import com.teammoeg.frostedheart.content.utility.gunpowder_barrel.GunpowderBarrelBlock; +import com.teammoeg.frostedheart.content.utility.gunpowder_barrel.GunpowderBarrelBlockItem; import com.teammoeg.frostedheart.content.utility.incinerator.GasVentBlock; import com.teammoeg.frostedheart.content.utility.incinerator.OilBurnerBlock; import com.teammoeg.frostedheart.infrastructure.gen.FHBlockStateGen; @@ -79,7 +73,6 @@ import com.teammoeg.frostedheart.item.FHBlockItem; import com.tterrag.registrate.providers.loot.RegistrateBlockLootTables; import com.tterrag.registrate.util.entry.BlockEntry; - import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.data.loot.packs.VanillaBlockLoot; import net.minecraft.tags.BlockTags; @@ -87,6 +80,7 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.PushReaction; @@ -99,10 +93,21 @@ import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import net.minecraftforge.common.Tags; +import net.minecraftforge.common.data.SoundDefinition; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +import static com.teammoeg.frostedheart.FHMain.REGISTRATE; +import static com.teammoeg.frostedheart.infrastructure.gen.FHBlockStateGen.ruinedMachines; +import static com.teammoeg.frostedheart.infrastructure.gen.FHTagGen.*; +import static net.minecraft.world.level.block.Blocks.*; + @SuppressWarnings("unused") public class FHBlocks { @@ -2024,6 +2029,43 @@ protected static RegistryObject register(String name, Suppl .tag(FHTags.Blocks.METAL_MACHINES.get()) .simpleItem() .register(); + // gunpowder_barrel + public static final RegistryObject GUNPOWDER_BARREL = register( + "gunpowder_barrel", + () -> new GunpowderBarrelBlock(BlockBehaviour.Properties.copy(TNT) + .sound(SoundType.WOOD) + .mapColor(SPRUCE_PLANKS.defaultMapColor())), + "gunpowder_barrel", + b -> new GunpowderBarrelBlockItem(new Item.Properties().stacksTo(1)) + ); + // Biogas System + public static final BlockEntry BIOGAS_DIGESTER_CONTROLLER = REGISTRATE.block("biogas_digester_controller", BiogasDigesterControllerBlock::new) + .initialProperties(() -> COPPER_BLOCK) + .properties(t->t.mapColor(IRON_BLOCK.defaultMapColor()) + .requiresCorrectToolForDrops()) + .transform(pickaxeOnly()) + .blockstate(FHBlockStateGen.existed()) + .loot(RegistrateBlockLootTables::dropSelf) + .tag(FHTags.Blocks.METAL_MACHINES.get()) + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .tag(BlockTags.NEEDS_STONE_TOOL) + .lang("Biogas Digester Controller") + .simpleItem() + .register(); + public static final BlockEntry BIOGAS_DIGESTER_IO = REGISTRATE.block("biogas_digester_io", BiogasDigesterIOBlock::new) + .initialProperties(() -> COPPER_BLOCK) + .properties(t->t.mapColor(IRON_BLOCK.defaultMapColor()) + .noOcclusion() + .requiresCorrectToolForDrops()) + .transform(pickaxeOnly()) + .loot(RegistrateBlockLootTables::dropSelf) + .blockstate(FHBlockStateGen.existed()) + .tag(FHTags.Blocks.METAL_MACHINES.get()) + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .tag(BlockTags.NEEDS_STONE_TOOL) + .lang("Biogas Digester Input & Output") + .simpleItem() + .register(); public static void init() { } public static final Map> SNOWY_TERRAIN_BLOCKS = new HashMap<>(new ImmutableMap.Builder>() diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHItems.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHItems.java index d404d4dfb..b436f253a 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHItems.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHItems.java @@ -27,6 +27,7 @@ import com.simibubi.create.foundation.item.ItemDescription; import com.teammoeg.caupona.CPTags; import com.teammoeg.frostedheart.FHMain; +import com.teammoeg.frostedheart.content.utility.gunpowder_barrel.GunpowderBarrelBlockItem; import com.teammoeg.frostedheart.content.utility.seld.SledItem; import com.teammoeg.frostedheart.item.DyedItemList; import com.teammoeg.frostedheart.bootstrap.reference.FHArmorMaterial; diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHMenuTypes.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHMenuTypes.java index b5ea29ea6..df9b2eeba 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHMenuTypes.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHMenuTypes.java @@ -19,6 +19,14 @@ package com.teammoeg.frostedheart.bootstrap.common; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterControllerBlockEntity; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterIOBlockEntity; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterControllerMenu; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterIOMenu; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.flag.FeatureFlagRegistry; import org.apache.commons.lang3.mutable.Mutable; import org.apache.commons.lang3.mutable.MutableObject; @@ -63,6 +71,8 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.Objects; + public class FHMenuTypes { @FunctionalInterface public interface BEMenuFactory { @@ -91,7 +101,9 @@ public interface BEMenuFactory> INCUBATOR_T2 = register(HeatIncubatorTileEntity.class, ("heat_incubator"), IncubatorT2Container::new); public static final RegistryObject> WARDROBE = register(WardrobeBlockEntity.class, ("wardrobe"), WardrobeMenu::new); - + public static final RegistryObject> BIOGAS_DIGESTER_CONTROLLER = CONTAINERS.register("biogas_digester_controller", () -> IForgeMenuType.create(BiogasDigesterControllerMenu::new)); + public static final RegistryObject> BIOGAS_DIGESTER_IO = CONTAINERS.register("biogas_digester_io", () -> IForgeMenuType.create(BiogasDigesterIOMenu::new)); + @SuppressWarnings("unchecked") public static RegistryObject> register(Class BEClass, String name, BEMenuFactory factory) { return CONTAINERS.register(name, () -> IForgeMenuType.create((id, inv, pb) -> { diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterControllerBlock.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterControllerBlock.java new file mode 100644 index 000000000..8932cc7ae --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterControllerBlock.java @@ -0,0 +1,57 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.block; + +import com.simibubi.create.content.equipment.wrench.IWrenchable; +import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; +import net.minecraftforge.registries.RegistryObject; +import org.jetbrains.annotations.Nullable; + +public class BiogasDigesterControllerBlock extends BaseEntityBlock implements IWrenchable { + public BiogasDigesterControllerBlock(Properties blockProps) { + super(blockProps); + } + + @Override + public RenderShape getRenderShape(BlockState pState) { + return RenderShape.MODEL; + } + @Override + public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { + if (pLevel.isClientSide){ + return InteractionResult.SUCCESS; + } + BlockEntity blockEntity = pLevel.getBlockEntity(pPos); + if (blockEntity instanceof BiogasDigesterControllerBlockEntity be) { + NetworkHooks.openScreen((ServerPlayer) pPlayer,be,pPos); + } + return InteractionResult.CONSUME; + } + @Nullable + @Override + public BlockEntityTicker getTicker(Level pLevel, BlockState pState, BlockEntityType pBlockEntityType) { + if (pLevel.isClientSide()){ + return null; + } + return createTickerHelper(pBlockEntityType, FHBlockEntityTypes.BIOGAS_DIGESTER_CONTROLLER.get(), + (pLevel1,pPos,pState1,blockEntity) -> blockEntity.tick(pLevel1,pPos)); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return new BiogasDigesterControllerBlockEntity(blockPos,blockState); + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterControllerBlockEntity.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterControllerBlockEntity.java new file mode 100644 index 000000000..7af9e7820 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterControllerBlockEntity.java @@ -0,0 +1,287 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.block; + +import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; +import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterControllerMenu; +import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.Nameable; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerData; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class BiogasDigesterControllerBlockEntity extends BlockEntity implements MenuProvider, Nameable { + public final ContainerData propertyDelegate; + private int yCounter = 1; + private int maxXCounter = 0; + private int maxZCounter = 0; + private int minXCounter = 0; + private int minZCounter = 0; + private int checked = 0; + private int size = 0; + @Getter + private int gasValue = 0; + private int maxGasValue = 0; + private int shortGasValue = 0; + private int isSplit = 0; + + public BiogasDigesterControllerBlockEntity(BlockPos pos, BlockState state) { + super(FHBlockEntityTypes.BIOGAS_DIGESTER_CONTROLLER.get(), pos, state); + this.propertyDelegate = new ContainerData() { + @Override + public int get(int index) { + return switch (index){ + case 0 -> BiogasDigesterControllerBlockEntity.this.checked; + case 1 -> BiogasDigesterControllerBlockEntity.this.size; + case 2 -> BiogasDigesterControllerBlockEntity.this.shortGasValue; + case 3 -> BiogasDigesterControllerBlockEntity.this.isSplit; + default -> 0; + }; + } + @Override + public void set(int index, int value) { + } + + @Override + public int getCount() { + return 4; + } + }; + } + + public boolean isChecked(){ + return checked != 0; + } + + public void addGas(int value){ + gasValue += value; + } + public void reduceGas(int value){ + if (gasValue > value){ + gasValue -= value; + } else { + gasValue = 0; + } + } + public int getCurrentSize(){ + return size; + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + } + + @Override + protected void saveAdditional(@NotNull CompoundTag pTag) { + super.saveAdditional(pTag); + pTag.putInt("GasValue",gasValue); + pTag.putInt("MaxGasValue",maxGasValue); + } + + @Override + public void load(@NotNull CompoundTag pTag) { + super.load(pTag); + gasValue = pTag.getInt("GasValue"); + maxGasValue = pTag.getInt("MaxGasValue"); + } + @Override + public @NotNull Component getDisplayName() { + return FHBlocks.BIOGAS_DIGESTER_CONTROLLER.get().getName(); + } + @Override + public @NotNull Component getName() { + return FHBlocks.BIOGAS_DIGESTER_CONTROLLER.get().getName(); + } + @Nullable + @Override + public AbstractContainerMenu createMenu(int syncId, @NotNull Inventory inventory, @NotNull Player player) { + return new BiogasDigesterControllerMenu(syncId, inventory,this, this.propertyDelegate); + } + private int time = 60; + + public void tick(Level world, BlockPos pos) { + time--; + if (time == 10) { + if (check(world)){ + checked = 1; + } else { + checked = 0; + size = 0; + } + restAll(); + } + if (checked==1){ + maxGasValue = size * 1000; + } else { + maxGasValue = 0; + } + if (gasValue >= Short.MAX_VALUE){ + shortGasValue = gasValue/19; + isSplit = 1; + } else { + shortGasValue = gasValue; + isSplit = 0; + } + if (gasValue > maxGasValue){ + if (time == 1){ + world.explode(null,pos.getX(),pos.getY(),pos.getZ(),3.5f,true, Level.ExplosionInteraction.BLOCK); + } + } + if (time <= 0){ + time = 60; + } + } + private boolean check(Level world){ + BlockPos maxPos; + BlockPos minPos; + int length; + int width; + if (world.getBlockState(getBlockPos().below()).isAir()){ + int maxValue = 5; + do { + yCounter++; + if (!world.getBlockState(getBlockPos().below(yCounter)).isAir()){ + yCounter--; + break; + } + } while (yCounter <= maxValue); + if (!world.getBlockState(getBlockPos().below(yCounter+1)).canOcclude()){ + return false; + } else { + do { + maxXCounter++; + if (!world.getBlockState(getBlockPos().east(maxXCounter).below(yCounter)).isAir()){ + maxXCounter--; + break; + } + } while (maxXCounter <= maxValue); + if (!world.getBlockState(getBlockPos().east(maxXCounter+1).below(yCounter)).canOcclude()){ + return false; + } else { + do { + maxZCounter++; + if (!world.getBlockState(getBlockPos().south(maxZCounter).below(yCounter)).isAir()){ + maxZCounter--; + break; + } + } while (maxZCounter <= maxValue); + if (!world.getBlockState(getBlockPos().south(maxZCounter+1).below(yCounter)).canOcclude()){ + return false; + } else { + maxPos = new BlockPos(getBlockPos().getX()+maxXCounter, + getBlockPos().getY()-yCounter,getBlockPos().getZ()+maxZCounter); + do { + minXCounter++; + if (!world.getBlockState(getBlockPos().west(minXCounter).below()).isAir()){ + minXCounter--; + break; + } + } while (minXCounter <= maxValue); + if (!world.getBlockState(getBlockPos().west(minXCounter+1).below()).canOcclude()){ + return false; + } else { + do { + minZCounter++; + if (!world.getBlockState(getBlockPos().north(minZCounter).below()).isAir()){ + minZCounter--; + break; + } + } while (minZCounter <= maxValue); + if (!world.getBlockState(getBlockPos().north(minZCounter+1).below()).canOcclude()){ + return false; + } else { + minPos = new BlockPos(getBlockPos().getX()-minXCounter, + getBlockPos().getY()-1,getBlockPos().getZ()-minZCounter); + length = maxZCounter + minZCounter+1; + width = maxXCounter + minXCounter+1; + BlockPos up = minPos.above(); + for (int s = 0;s < length;s++){ + for (int e = 0;e < width;e++){ + if (world.getBlockState(new BlockPos(up.getX()+e,up.getY(),up.getZ()+s)).getBlock() == FHBlocks.BIOGAS_DIGESTER_CONTROLLER.get()){ + if (!(up.getX()+ e == getBlockPos().getX()&&up.getZ() + s==getBlockPos().getZ())){ + return false; + } + } + if (!world.getBlockState(new BlockPos(up.getX()+e,up.getY(),up.getZ()+s)).canOcclude()){ + return false; + } + } + } + BlockPos north = minPos.north(); + for (int e = 0;e < length;e++){ + for (int d = 0;d < yCounter;d++){ + if (!world.getBlockState(new BlockPos(north.getX()+e,north.getY()-d,north.getZ())).canOcclude()){ + return false; + } + } + } + BlockPos west = minPos.west(); + for (int d = 0;d < yCounter;d++){ + for (int s = 0;s < length;s++){ + if (!world.getBlockState(new BlockPos(west.getX(),west.getY()-d,west.getZ()+s)).canOcclude()){ + return false; + } + } + } + BlockPos down = maxPos.below(); + for (int n = 0;n < length;n++){ + for (int w = 0;w < width;w++){ + if (!world.getBlockState(new BlockPos(down.getX()-w,down.getY(),down.getZ()-n)).canOcclude()){ + return false; + } + } + } + BlockPos east = maxPos.east(); + for (int n = 0;n < length;n++){ + for (int u = 0;u < yCounter;u++){ + if (!world.getBlockState(new BlockPos(east.getX(),east.getY()+u,east.getZ()-n)).canOcclude()){ + return false; + } + } + } + BlockPos south = maxPos.south(); + for (int u = 0;u < yCounter;u++){ + for (int w = 0;w pBuilder) { + pBuilder.add(WATERLOGGED); + } + @Nullable + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + FluidState fluidState = context.getLevel().getFluidState(context.getClickedPos()); + return defaultBlockState().setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); + } + + @Override + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { + if (Boolean.TRUE.equals(state.getValue(WATERLOGGED))) { + world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + } + return direction == Direction.DOWN && !state.canSurvive(world, pos) ? Blocks.AIR.defaultBlockState() + : super.updateShape(state, direction, newState, world, pos, posFrom); + } + + @Override + public FluidState getFluidState(BlockState state) { + return Boolean.TRUE.equals(state.getValue(WATERLOGGED)) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + } + + @Override + public RenderShape getRenderShape(BlockState pState) { + return RenderShape.MODEL; + } + + @Override + public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + return SHAPED; + } + + @Override + public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + return SHAPED; + } + + @Override + public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { + if (pState.getBlock() != pNewState.getBlock()){ + BlockEntity blockEntity = pLevel.getBlockEntity(pPos); + if (blockEntity instanceof BiogasDigesterIOBlockEntity entity){ + entity.drops(); + } + } + super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new BiogasDigesterIOBlockEntity(pos, state); + } + + @Override + public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { + if (pLevel.isClientSide){ + return InteractionResult.SUCCESS; + } + BlockEntity blockEntity = pLevel.getBlockEntity(pPos); + if (blockEntity instanceof BiogasDigesterIOBlockEntity be) { + NetworkHooks.openScreen((ServerPlayer) pPlayer,be,pPos); + } + return InteractionResult.CONSUME; + } + + @Nullable + @Override + public BlockEntityTicker getTicker(Level pLevel, BlockState pState, BlockEntityType pBlockEntityType) { + if (pLevel.isClientSide()){ + return null; + } + return createTickerHelper(pBlockEntityType, FHBlockEntityTypes.BIOGAS_DIGESTER_IO.get(), + (pLevel1,pPos,pState1,blockEntity) -> blockEntity.tick(pLevel1,pPos)); + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterIOBlockEntity.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterIOBlockEntity.java new file mode 100644 index 000000000..f9e6f4b98 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/block/BiogasDigesterIOBlockEntity.java @@ -0,0 +1,309 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.block; + +import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; +import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.BiogasDigesterIOMenu; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.*; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerData; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class BiogasDigesterIOBlockEntity extends BlockEntity implements Nameable, MenuProvider, WorldlyContainer { + public BiogasDigesterIOBlockEntity(BlockPos pos, BlockState state) { + super(FHBlockEntityTypes.BIOGAS_DIGESTER_IO.get(), pos, state); + this.propertyDelegate = new ContainerData() { + @Override + public int get(int index) { + return switch (index) { + case 0 -> BiogasDigesterIOBlockEntity.this.progress; + case 1 -> BiogasDigesterIOBlockEntity.this.maxProgress; + case 2 -> BiogasDigesterIOBlockEntity.this.shortGasValue; + case 3 -> BiogasDigesterIOBlockEntity.this.checked; + case 4 -> BiogasDigesterIOBlockEntity.this.isSplit; + default -> 0; + }; + } + + @Override + public void set(int index, int value) { + } + + @Override + public int getCount() { + return 5; + } + }; + } + private final ItemStackHandler inventory = new ItemStackHandler(12); + + private static final Item DIGESTATE = Items.BONE_MEAL; + + private LazyOptional lazyItemHandler = LazyOptional.empty(); + private int progress = 0; + private int maxProgress = 0; + private int gasValue = 0; + private int checked = 0; + private int counter = 0; + private int shortGasValue = 0; + private int isSplit = 0; + protected final ContainerData propertyDelegate; + + @Override + public @NotNull LazyOptional getCapability(@NotNull Capability cap) { + if (cap == ForgeCapabilities.ITEM_HANDLER){ + return lazyItemHandler.cast(); + } + return super.getCapability(cap); + } + + @Override + public void onLoad() { + super.onLoad(); + lazyItemHandler = LazyOptional.of(() -> inventory); + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + lazyItemHandler.invalidate(); + } + + @Override + protected void saveAdditional(CompoundTag nbt) { + nbt.put("Inventory", inventory.serializeNBT()); + nbt.putInt("Progress",progress); + nbt.putInt("MaxProgress", maxProgress); + nbt.putBoolean("IsCrafting", isCrafting); + nbt.putInt("TempGasValue", tempGasValue); + nbt.putInt("Counter", counter); + super.saveAdditional(nbt); + } + + @Override + public void load(@NotNull CompoundTag nbt) { + super.load(nbt); + inventory.deserializeNBT(nbt.getCompound("Inventory")); + progress = nbt.getInt("Progress"); + maxProgress = nbt.getInt("MaxProgress"); + isCrafting = nbt.getBoolean("IsCrafting"); + tempGasValue = nbt.getInt("TempGasValue"); + counter = nbt.getInt("Counter"); + } + + @Override + public int[] getSlotsForFace(@NotNull Direction side) { + int[] result = new int[inventory.getSlots()]; + for (int i = 0; i < result.length; i++) { + result[i] = i; + } + return result; + } + + @Override + public boolean canPlaceItemThroughFace(int slot, @NotNull ItemStack stack, @Nullable Direction dir) { + return slot >= 0 && slot <= 8; + } + + @Override + public boolean canTakeItemThroughFace(int slot, @NotNull ItemStack stack, @NotNull Direction dir) { + return slot >= 9 && slot <= 11; + } + + @Override + public Component getName() { + return FHBlocks.BIOGAS_DIGESTER_IO.get().getName(); + } + + @Override + public Component getDisplayName() { + return FHBlocks.BIOGAS_DIGESTER_IO.get().getName(); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(int syncId, Inventory playerInventory, Player player) { + return new BiogasDigesterIOMenu(syncId, playerInventory,this,this.propertyDelegate); + } + + private boolean isCrafting = false; + private int tempGasValue = 0; + public void tick(Level world, BlockPos pos) { + if (world.getBlockEntity(pos.below()) instanceof BiogasDigesterControllerBlockEntity entity){ + if (entity.isChecked()){ + checked = 1; + gasValue = entity.getGasValue(); + maxProgress = entity.getCurrentSize(); + if (gasValue > Short.MAX_VALUE){ + shortGasValue = gasValue/19; + isSplit = 1; + } else { + shortGasValue = gasValue; + isSplit = 0; + } + if (!isCrafting){ + for (int i = 0;i<9;i++){ + Item item = inventory.getStackInSlot(i).getItem().asItem(); + if (isFood(item)){ + FoodProperties foodProperties = item.getFoodProperties(); + tempGasValue = (int) (foodProperties.getNutrition() * 10 + foodProperties.getSaturationModifier() * 200); + inventory.extractItem(i,1,false); + isCrafting = true; + break; + } + } + } else { + inCreaseProgress(); + if (progress == maxProgress){ + entity.addGas(tempGasValue); + resetProgress(); + counter += world.random.nextIntBetweenInclusive(0,4); + if (counter >= 32){ + putItem(world); + counter = 0; + } + tempGasValue = 0; + isCrafting = false; + } + } + } + } else { + checked = 0; + gasValue = 0; + maxProgress = 0; + tempGasValue = 0; + isCrafting = false; + resetProgress(); + } + } + + public void drops(){ + SimpleContainer inv = new SimpleContainer(inventory.getSlots()); + for(int i = 0; i < inventory.getSlots(); i++){ + inv.setItem(i, inventory.getStackInSlot(i)); + } + Containers.dropContents(this.level,this.worldPosition,inv); + } + + private void putItem(Level world) { + boolean hasSpawn = false; + for (int i = 9;i<12;i++){ + if (inventory.getStackInSlot(i).isEmpty()){ + inventory.setStackInSlot(i, DIGESTATE.getDefaultInstance()); + hasSpawn = true; + break; + } else if (inventory.getStackInSlot(i).getItem().equals(DIGESTATE)){ + int count = inventory.getStackInSlot(i).getCount(); + if (count < inventory.getStackInSlot(i).getMaxStackSize()){ + inventory.setStackInSlot(i,new ItemStack(DIGESTATE,count+1)); + hasSpawn = true; + break; + } + } + } + if (!hasSpawn){ + BlockPos pos = getBlockPos().above(); + ItemEntity item = new ItemEntity(world,pos.getX(),pos.getY(),pos.getZ(),new ItemStack(DIGESTATE)); + item.setDeltaMovement(0.0,0.5,0.0); + world.addFreshEntity(item); + } + } + + private void resetProgress() { + progress = 0; + } + + private void inCreaseProgress() { + progress++; + } + + public boolean isFood(Item item){ + return item.isEdible(); + } + + @Override + public int getContainerSize() { + return 12; + } + + @Override + public boolean isEmpty() { + boolean empty = true; + for(int i = 0; i < inventory.getSlots(); i++){ + if (!inventory.getStackInSlot(i).isEmpty()){ + empty = false; + break; + } + } + return empty; + } + + @Override + public ItemStack getItem(int i) { + return inventory.getStackInSlot(i); + } + + @Override + public ItemStack removeItem(int pIndex, int pCount) { + List list = new ArrayList<>(inventory.getSlots()); + for(int i = 0; i < inventory.getSlots(); i++){ + list.add(i,inventory.getStackInSlot(i)); + } + ItemStack removeItem = ContainerHelper.removeItem(list, pIndex, pCount); + if (!removeItem.isEmpty()) { + this.setChanged(); + } + return removeItem; + } + + @Override + public ItemStack removeItemNoUpdate(int i) { + ItemStack itemStack = this.inventory.getStackInSlot(i); + if (itemStack.isEmpty()) { + return ItemStack.EMPTY; + } else { + this.inventory.setStackInSlot(i, ItemStack.EMPTY); + return itemStack; + } + } + + @Override + public void setItem(int i, ItemStack itemStack) { + inventory.setStackInSlot(i,itemStack); + } + + @Override + public boolean stillValid(Player player) { + return Container.stillValidBlockEntity(this, player); + } + + @Override + public void clearContent() { + for(int i = 0;i < inventory.getSlots();i++){ + inventory.setStackInSlot(i,ItemStack.EMPTY); + } + this.setChanged(); + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterControllerMenu.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterControllerMenu.java new file mode 100644 index 000000000..e9353c77f --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterControllerMenu.java @@ -0,0 +1,96 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.screen; + +import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; +import com.teammoeg.frostedheart.bootstrap.common.FHMenuTypes; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterControllerBlockEntity; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.*; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; + +public class BiogasDigesterControllerMenu extends AbstractContainerMenu { + private final ContainerData propertyDelegate; + private final Level level; + public final BiogasDigesterControllerBlockEntity blockEntity; + public BiogasDigesterControllerMenu(int syncId, Inventory inv, FriendlyByteBuf buf){ + this(syncId, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(4)); + } + public BiogasDigesterControllerMenu(int syncId, Inventory playerInventory, + BlockEntity blockEntity, ContainerData propertyDelegate){ + super(FHMenuTypes.BIOGAS_DIGESTER_CONTROLLER.get(),syncId); + this.propertyDelegate = propertyDelegate; + this.blockEntity = (BiogasDigesterControllerBlockEntity) blockEntity; + this.level = playerInventory.player.level(); + + addPlayerHotbar(playerInventory); + addPlayerInventory(playerInventory); + + addDataSlots(propertyDelegate); + } + + + public int getChecked(){ + return this.propertyDelegate.get(0); + } + + public int getSize(){ + return this.propertyDelegate.get(1); + } + + public int getGasValue(){ + int gasValue = this.propertyDelegate.get(2); + if (this.propertyDelegate.get(3) != 0){ + gasValue = gasValue * 19; + } + return gasValue; + } + + @Override + public ItemStack quickMoveStack(Player player, int slot) { + ItemStack itemStack = ItemStack.EMPTY; + Slot slot2 = this.slots.get(slot); + if (slot2.hasItem()) { + ItemStack itemStack2 = slot2.getItem(); + itemStack = itemStack2.copy(); + if (slot >= 0 && slot < 27) { + if (!this.moveItemStackTo(itemStack2, 27, 36, false)) { + return ItemStack.EMPTY; + } + } else if (slot >= 27 && slot < 36 && !this.moveItemStackTo(itemStack2, 0, 27, false)) { + return ItemStack.EMPTY; + } + if (itemStack2.isEmpty()) { + slot2.set(ItemStack.EMPTY); + } + slot2.setChanged(); + if (itemStack2.getCount() == itemStack.getCount()) { + return ItemStack.EMPTY; + } + slot2.onTake(player, itemStack2); + this.broadcastChanges(); + } + return itemStack; + } + + @Override + public boolean stillValid(Player player) { + return stillValid(ContainerLevelAccess.create(level,blockEntity.getBlockPos()), player, + FHBlocks.BIOGAS_DIGESTER_CONTROLLER.get()); + } + private void addPlayerInventory(Inventory playerInventory){ + for (int i = 0; i < 3; ++i){ + for (int l = 0; l < 9; ++l){ + this.addSlot(new Slot(playerInventory, l + i * 9 +9, 8 +l *18, 84 +i * 18)); + } + } + } + private void addPlayerHotbar(Inventory playerInventory){ + for (int i = 0; i < 9; ++i){ + this.addSlot(new Slot (playerInventory, i, 8 + i * 18, 142)); + } + } + +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterControllerScreen.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterControllerScreen.java new file mode 100644 index 000000000..279529e68 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterControllerScreen.java @@ -0,0 +1,80 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.screen; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.teammoeg.frostedheart.FHMain; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; + +public class BiogasDigesterControllerScreen extends AbstractContainerScreen { + private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(FHMain.MODID, + "textures/gui/biogas_digester_controller_gui.png"); + + public BiogasDigesterControllerScreen(BiogasDigesterControllerMenu handler, Inventory inventory, Component title) { + super(handler, inventory, title); + } + boolean b1; + boolean b2; + boolean b3; + boolean b4; + @Override + protected void init() { + super.init(); + titleLabelX = (imageWidth - font.width(title)) / 2; + } + @Override + protected void renderBg(GuiGraphics context, float delta, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1f,1f,1f,1f); + RenderSystem.setShaderTexture(0,TEXTURE); + int x = (width - imageWidth) / 2; + int y = (height - imageHeight) / 2; + + context.blit(TEXTURE, x, y, 0, 0, imageWidth,imageHeight); + + context.drawString(font,String.valueOf(menu.getSize()),x+70,y+22,0xffffff,true); + context.drawString(font,String.valueOf(menu.getGasValue()),x+70,y+38,0x00ff00,true); + context.drawString(font,String.valueOf(menu.getSize() * 1000),x+70,y+54,0xff0000,true); + b1 = mouseX >= x + 52 && mouseY >= y + 19 && mouseX <= x + 65 && mouseY <= y + 33; + b2 = mouseX >= x + 52 && mouseY >= y + 35 && mouseX <= x + 65 && mouseY <= y + 49; + b3 = mouseX >= x + 52 && mouseY >= y + 51 && mouseX <= x + 65 && mouseY <= y + 65; + + if (menu.getChecked()==1){ + context.blit(TEXTURE,x+9,y+58,176,0,25,12); + b4 = false; + } else { + b4 = mouseX >= x + 9 && mouseY >= y + 58 && mouseX <= x + 33 && mouseY <= y + 69; + } + if (mouseX >= x + 161 && mouseX <= x + 171 && mouseY >= y + 5 && mouseY <= y + 15){ + context.blit(TEXTURE,x+161,y+5,194,13,11,11); + } + } + + @Override + protected void renderTooltip(GuiGraphics context, int mouseX, int mouseY) { + if (b1){ + context.renderTooltip(font,Component.translatable("gui.frostedheart.biogas_digester_controller_menu.size").withStyle(ChatFormatting.WHITE),mouseX,mouseY); + } + if (b2){ + context.renderTooltip(font,Component.translatable("gui.frostedheart.biogas_digester_controller_menu.gas_value").withStyle(ChatFormatting.GREEN),mouseX,mouseY); + } + if (b3){ + context.renderTooltip(font,Component.translatable("gui.frostedheart.biogas_digester_controller_menu.max_gas_value").withStyle(ChatFormatting.RED),mouseX,mouseY); + } + if (b4){ + context.renderTooltip(font,Component.translatable("gui.frostedheart.biogas_digester_controller_menu.unavailable").withStyle(ChatFormatting.RED),mouseX,mouseY); + } + super.renderTooltip(context, mouseX, mouseY); + } + + @Override + public void render(GuiGraphics context, int mouseX, int mouseY, float delta) { + renderBackground(context); + super.render(context, mouseX, mouseY, delta); + renderTooltip(context, mouseX, mouseY); + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterIOMenu.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterIOMenu.java new file mode 100644 index 000000000..8c5b20ec7 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterIOMenu.java @@ -0,0 +1,129 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.screen; + +import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; +import com.teammoeg.frostedheart.bootstrap.common.FHMenuTypes; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterIOBlockEntity; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.utils.OnlyExtractSlot; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.*; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.items.SlotItemHandler; + +import java.util.concurrent.atomic.AtomicBoolean; + +public class BiogasDigesterIOMenu extends AbstractContainerMenu { + private final ContainerData propertyDelegate; + public final BiogasDigesterIOBlockEntity blockEntity; + private final Level level; + public BiogasDigesterIOMenu(int syncId, Inventory inventory, FriendlyByteBuf buf){ + this(syncId, inventory, inventory.player.level().getBlockEntity(buf.readBlockPos()), + new SimpleContainerData(5)); + } + public BiogasDigesterIOMenu(int syncId, Inventory inventory, + BlockEntity blockEntity, ContainerData arrayPropertyDelegate){ + super(FHMenuTypes.BIOGAS_DIGESTER_IO.get(),syncId); + checkContainerSize(inventory,12); + this.level = inventory.player.level(); + this.propertyDelegate = arrayPropertyDelegate; + this.blockEntity = ((BiogasDigesterIOBlockEntity) blockEntity); + + this.blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(iItemHandler -> { + this.addSlot(new SlotItemHandler(iItemHandler,0,8,19)); + this.addSlot(new SlotItemHandler(iItemHandler,1,26,19)); + this.addSlot(new SlotItemHandler(iItemHandler,2,44,19)); + this.addSlot(new SlotItemHandler(iItemHandler,3,8,37)); + this.addSlot(new SlotItemHandler(iItemHandler,4,26,37)); + this.addSlot(new SlotItemHandler(iItemHandler,5,44,37)); + this.addSlot(new SlotItemHandler(iItemHandler,6,8,55)); + this.addSlot(new SlotItemHandler(iItemHandler,7,26,55)); + this.addSlot(new SlotItemHandler(iItemHandler,8,44,55)); + + this.addSlot(new OnlyExtractSlot(iItemHandler,9,152,19)); + this.addSlot(new OnlyExtractSlot(iItemHandler,10,152,37)); + this.addSlot(new OnlyExtractSlot(iItemHandler,11,152,55)); + }); + addPlayerHotbar(inventory); + addPlayerInventory(inventory); + + addDataSlots(arrayPropertyDelegate); + } + public boolean isCrafting(){ + return propertyDelegate.get(0) > 0; + } + public int getGasValue(){ + int gasValue = this.propertyDelegate.get(2); + if (this.propertyDelegate.get(4) != 0){ + gasValue = gasValue * 19; + } + return gasValue; + } + public boolean isChecked(){ + return this.propertyDelegate.get(3) != 0; + } + public int getScaledProgress(){ + int progress = this.propertyDelegate.get(0); + int maxProgress = this.propertyDelegate.get(1); // Max Progress + int progressArrowSize = 84;// Arrow's Width + + return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0; + } + + @Override + public ItemStack quickMoveStack(Player player, int invSlot) { + ItemStack newStack = ItemStack.EMPTY; + Slot slot = this.slots.get(invSlot); + AtomicBoolean r = new AtomicBoolean(true); + if (slot.hasItem()) { + ItemStack originalStack = slot.getItem(); + newStack = originalStack.copy(); + if (!this.blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).isPresent()){ + return ItemStack.EMPTY; + } + this.blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(iItemHandler -> { + if (invSlot < iItemHandler.getSlots()) { + if (!moveItemStackTo(originalStack, iItemHandler.getSlots(), this.slots.size(), true)) { + r.set(false); + return; + } + } else if (!moveItemStackTo(originalStack, 0, iItemHandler.getSlots(), false)) { + r.set(false); + return; + } + if (originalStack.isEmpty()) { + slot.set(ItemStack.EMPTY); + } else { + slot.setChanged(); + } + }); + } + if (r.get()){ + return newStack; + } else { + return ItemStack.EMPTY; + } + } + + @Override + public boolean stillValid(Player player) { + return stillValid(ContainerLevelAccess.create(level,blockEntity.getBlockPos()), player, + FHBlocks.BIOGAS_DIGESTER_IO.get()); + } + private void addPlayerInventory(Inventory playerInventory){ + for (int i = 0; i < 3; ++i){ + for (int l = 0; l < 9; ++l){ + this.addSlot(new Slot(playerInventory, l + i * 9 +9, 8 +l *18, 84 +i * 18)); + } + } + } + private void addPlayerHotbar(Inventory playerInventory){ + for (int i = 0; i < 9; ++i){ + this.addSlot(new Slot (playerInventory, i, 8 + i * 18, 142)); + } + } + +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterIOScreen.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterIOScreen.java new file mode 100644 index 000000000..93e189af6 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/BiogasDigesterIOScreen.java @@ -0,0 +1,63 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.screen; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.teammoeg.frostedheart.FHMain; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; + +public class BiogasDigesterIOScreen extends AbstractContainerScreen { + private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(FHMain.MODID, + "textures/gui/biogas_digester_io_gui.png"); + + public BiogasDigesterIOScreen(BiogasDigesterIOMenu handler, Inventory inventory, Component title) { + super(handler, inventory, title); + } + boolean b; + @Override + protected void init() { + super.init(); + titleLabelX = (imageWidth - font.width(title)) / 2; + } + @Override + protected void renderBg(GuiGraphics context, float delta, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1f,1f,1f,1f); + RenderSystem.setShaderTexture(0,TEXTURE); + int x = (width - imageWidth) / 2; + int y = (height - imageHeight) / 2; + + context.blit(TEXTURE, x, y, 0, 0, imageWidth,imageHeight); + + renderProgressArrow(context, x, y); + if (menu.isChecked()){ + context.blit(TEXTURE,x+123,y+60,176,0,25,12); + } + b = mouseX >= x + 108 && mouseX <= x + 121 && mouseY >= y + 60 && mouseY <= y + 71; + } + + private void renderProgressArrow(GuiGraphics context, int x, int y) { + if (menu.isCrafting()){ + context.blit(TEXTURE, x + 64, y + 36, 0, 166, menu.getScaledProgress(), 18); + } + } + + @Override + protected void renderTooltip(GuiGraphics pGuiGraphics, int pX, int pY) { + if (b){ + pGuiGraphics.renderTooltip(font,Component.literal(menu.getGasValue() + " L").withStyle(ChatFormatting.WHITE),pX,pY); + } + super.renderTooltip(pGuiGraphics, pX, pY); + } + + @Override + public void render(GuiGraphics context, int mouseX, int mouseY, float delta) { + renderBackground(context); + super.render(context, mouseX, mouseY, delta); + renderTooltip(context, mouseX, mouseY); + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/utils/OnlyExtractSlot.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/utils/OnlyExtractSlot.java new file mode 100644 index 000000000..c14d6b322 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/utils/OnlyExtractSlot.java @@ -0,0 +1,19 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.utils; + +import net.minecraft.world.Container; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.SlotItemHandler; + +public class OnlyExtractSlot extends SlotItemHandler { + + public OnlyExtractSlot(IItemHandler itemHandler, int index, int xPosition, int yPosition) { + super(itemHandler, index, xPosition, yPosition); + } + + @Override + public boolean mayPlace(ItemStack pStack) { + return false; + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/utils/OnlyShowSlot.java b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/utils/OnlyShowSlot.java new file mode 100644 index 000000000..23d9a560c --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/agriculture/biogassystem/screen/utils/OnlyShowSlot.java @@ -0,0 +1,23 @@ +package com.teammoeg.frostedheart.content.agriculture.biogassystem.screen.utils; + +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.SlotItemHandler; + +public class OnlyShowSlot extends SlotItemHandler { + + public OnlyShowSlot(IItemHandler itemHandler, int index, int xPosition, int yPosition) { + super(itemHandler, index, xPosition, yPosition); + } + + @Override + public boolean mayPlace(ItemStack pStack) { + return false; + } + + @Override + public boolean mayPickup(Player pPlayer) { + return false; + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlock.java b/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlock.java new file mode 100644 index 000000000..654161b90 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlock.java @@ -0,0 +1,127 @@ +package com.teammoeg.frostedheart.content.utility.gunpowder_barrel; + +import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; +import com.teammoeg.frostedheart.content.agriculture.biogassystem.block.BiogasDigesterIOBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.util.RandomSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.FurnaceBlock; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; + +public class GunpowderBarrelBlock extends BaseEntityBlock { + public GunpowderBarrelBlock(Properties pProperties) { + super(pProperties); + } + public static final BooleanProperty LIT = BooleanProperty.create("lit"); + private static final VoxelShape SHAPED = Block.box(2,0,2,14,16,14); + + @Nullable + @Override + public BlockState getStateForPlacement(BlockPlaceContext pContext) { + return this.defaultBlockState().setValue(LIT,false); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { + pBuilder.add(LIT); + } + + @Override + public RenderShape getRenderShape(BlockState pState) { + return RenderShape.MODEL; + } + + @Override + public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + return SHAPED; + } + + @Override + public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + return SHAPED; + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return new GunpowderBarrelBlockEntity(blockPos,blockState); + } + + @Override + public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) { + if (pState.getBlock() != pNewState.getBlock()){ + BlockEntity blockEntity = pLevel.getBlockEntity(pPos); + if (blockEntity instanceof GunpowderBarrelBlockEntity entity){ + entity.drops(); + } + } + super.onRemove(pState, pLevel, pPos, pNewState, pMovedByPiston); + } + public void animateTick(BlockState pState, Level pLevel, BlockPos pPos, RandomSource pRandom) { + if (pState.getValue(LIT)) { + double x = (double)pPos.getX() + .5; + double y = pPos.getY() + 1; + double z = (double)pPos.getZ() + .5; + for (int i = 0; i < 3; i++){ + pLevel.addParticle(ParticleTypes.POOF, x, y, z, (pRandom.nextDouble()-0.5)/3, pRandom.nextDouble()/5, (pRandom.nextDouble()-0.5)/3); + pLevel.addParticle(ParticleTypes.SMOKE, x, y, z, (pRandom.nextDouble()-0.5)/3, pRandom.nextDouble()/5, (pRandom.nextDouble()-0.5)/3); + pLevel.addParticle(ParticleTypes.FLAME, x, y, z, (pRandom.nextDouble()-0.5)/3, pRandom.nextDouble()/5, (pRandom.nextDouble()-0.5)/3); + } + } + } + @Nullable + @Override + public BlockEntityTicker getTicker(Level pLevel, BlockState pState, BlockEntityType pBlockEntityType) { + if (pLevel.isClientSide()){ + return null; + } + return createTickerHelper(pBlockEntityType, FHBlockEntityTypes.GUNPOWDER_BARREL.get(), + (pLevel1,pPos,pState1,blockEntity) -> blockEntity.tick(pLevel1,pPos,pState1)); + } + + @Override + public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { + ItemStack stack = pPlayer.getItemInHand(pHand); + if (stack.getItem() == Items.FLINT_AND_STEEL){ + pLevel.playLocalSound(pPos.getX(), pPos.getY(), pPos.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F, false); + if (!pLevel.isClientSide()){ + pLevel.setBlock(pPos,pState.setValue(LIT,true),Block.UPDATE_ALL); + stack.hurtAndBreak(1, (LivingEntity) pPlayer, playerEntity -> playerEntity.broadcastBreakEvent(pHand)); + } + return InteractionResult.SUCCESS; + } else if (stack.getItem() == Items.FIRE_CHARGE) { + pLevel.playLocalSound(pPos.getX(), pPos.getY(), pPos.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F, false); + if (!pLevel.isClientSide()){ + pLevel.setBlock(pPos,pState.setValue(LIT,true),Block.UPDATE_ALL); + stack.setCount(stack.getCount()-1); + } + return InteractionResult.SUCCESS; + } else { + return InteractionResult.PASS; + } + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlockEntity.java b/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlockEntity.java new file mode 100644 index 000000000..b78a9a483 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlockEntity.java @@ -0,0 +1,189 @@ +package com.teammoeg.frostedheart.content.utility.gunpowder_barrel; + +import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; +import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.ExplosionDamageCalculator; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.event.ForgeEventFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Objects; + +public class GunpowderBarrelBlockEntity extends BlockEntity { + + public GunpowderBarrelBlockEntity(BlockPos pPos, BlockState pBlockState) { + super(FHBlockEntityTypes.GUNPOWDER_BARREL.get(), pPos, pBlockState); + } + int power = 1; + int fortune = 0; + int timer = 0; + boolean isExploding = false; + + public boolean isExploding() { + return isExploding; + } + + public void setExploding(boolean exploding) { + isExploding = exploding; + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + } + + @Override + protected void saveAdditional(@NotNull CompoundTag pTag) { + super.saveAdditional(pTag); + pTag.putInt("Power",power); + pTag.putInt("Fortune",fortune); + pTag.putInt("Timer", timer); + } + + @Override + public void load(@NotNull CompoundTag pTag) { + super.load(pTag); + power = pTag.getInt("Power"); + fortune = pTag.getInt("Fortune"); + timer = pTag.getInt("Timer"); + } + public void drops() { + if (!Objects.requireNonNull(getLevel()).isClientSide()){ + if (this.getBlockState().getValue(GunpowderBarrelBlock.LIT)){ + return; + } + ItemStack stack = new ItemStack(FHBlocks.GUNPOWDER_BARREL.get()); + CompoundTag nbt = new CompoundTag(); + nbt.putInt("Power",power); + nbt.putInt("Fortune",fortune); + BlockItem.setBlockEntityData(stack,FHBlockEntityTypes.GUNPOWDER_BARREL.get(),nbt); + ItemEntity item = new ItemEntity(getLevel(), + getBlockPos().getX()+.5,getBlockPos().getY()+.5,getBlockPos().getZ()+.5, + stack); + item.setNoPickUpDelay(); + getLevel().addFreshEntity(item); + } + } + public static void breakBlockWithFortune(Level level, BlockPos pos, int fortune) { + BlockState state = level.getBlockState(pos); + if (state.getBlock().getExplosionResistance() > 1000f) { + return; + } + ItemStack fakeTool = new ItemStack(Items.NETHERITE_PICKAXE); + if (fortune > 0){ + fakeTool.enchant(Enchantments.BLOCK_FORTUNE, fortune); + } + LootParams.Builder lootBuilder = new LootParams.Builder((ServerLevel) level) + .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos)) + .withParameter(LootContextParams.TOOL, fakeTool) + .withParameter(LootContextParams.THIS_ENTITY, null) + .withParameter(LootContextParams.BLOCK_STATE, state); + List drops = state.getDrops(lootBuilder); + for (ItemStack stack : drops) { + Block.popResource(level, pos, stack); + } + level.removeBlock(pos, false); + } + public static void createSafeExplosion(Level level, BlockPos pos, float power) { + ServerLevel serverLevel = (ServerLevel) level; + Vec3 center = Vec3.atCenterOf(pos); + + double radius = power * 2.0; + AABB area = new AABB( + pos.getX() - radius, pos.getY() - radius, pos.getZ() - radius, + pos.getX() + radius, pos.getY() + radius, pos.getZ() + radius + ); + + for (Entity entity : serverLevel.getEntities(null, area)) { + if (!(entity instanceof LivingEntity)) continue; + + Vec3 entityPos = entity.position(); + double distance = entityPos.distanceTo(center); + + double damageFactor = (1.0 - (distance / radius)) * power; + if (damageFactor <= 0) continue; + + float damage = (float) ((damageFactor * damageFactor + damageFactor) * 7.0 + 1.0); + entity.hurt(serverLevel.damageSources().explosion(null), damage); + + Vec3 knockbackVec = entityPos.subtract(center).normalize(); + double knockbackPower = damageFactor * 2.0; + + entity.setDeltaMovement( + entity.getDeltaMovement().add( + knockbackVec.x * knockbackPower, + knockbackVec.y * knockbackPower + 0.5, + knockbackVec.z * knockbackPower + ) + ); + } + for (int i = 0; i < 20; i++) { + serverLevel.sendParticles( + ParticleTypes.EXPLOSION, + center.x + (level.random.nextDouble() - 0.5), + center.y + 0.5, + center.z + (level.random.nextDouble() - 0.5), + 1, + 0, 0, 0, + 0.5 + ); + } + serverLevel.playSound( + null, + pos, + SoundEvents.GENERIC_EXPLODE, + SoundSource.BLOCKS, + 4.0F, + (1.0F + (level.random.nextFloat() - level.random.nextFloat()) * 0.2F) * 0.7F + ); + } + public void tick(Level pLevel, BlockPos pPos, BlockState pState) { + if (pLevel.isClientSide()){ + return; + } + if(pState.getValue(GunpowderBarrelBlock.LIT)){ + timer++; + if (timer > 80){ + createSafeExplosion(pLevel,pPos,3.0f+power); + for (int x = -power; x <= power; x++){ + for (int y = -power; y <= power; y++){ + for(int z = -power; z <= power; z++){ + if (x==0&&y==0&&z==0) continue; + breakBlockWithFortune(pLevel, + new BlockPos(pPos.getX()+x,pPos.getY()+y,pPos.getZ()+z), + fortune); + } + } + } + pLevel.removeBlock(pPos,false); + } + } + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlockItem.java b/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlockItem.java new file mode 100644 index 000000000..9712f0622 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/utility/gunpowder_barrel/GunpowderBarrelBlockItem.java @@ -0,0 +1,52 @@ +package com.teammoeg.frostedheart.content.utility.gunpowder_barrel; + +import com.simibubi.create.AllEnchantments; +import com.teammoeg.frostedheart.bootstrap.common.FHBlocks; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class GunpowderBarrelBlockItem extends BlockItem { + public GunpowderBarrelBlockItem(Properties pProperties) { + super(FHBlocks.GUNPOWDER_BARREL.get(), pProperties); + } + public static int getFortuneFromNBT(ItemStack stack){ + int i = 0; + CompoundTag nbt = BlockItem.getBlockEntityData(stack); + if (nbt != null && nbt.contains("Fortune")) { + i = nbt.getInt("Fortune"); + } + return i; + } + public static int getPowerFromNBT(ItemStack stack){ + int power = 1; + CompoundTag nbt = BlockItem.getBlockEntityData(stack); + if (nbt != null && nbt.contains("Power")) { + power = nbt.getInt("Power"); + } + return power; + } + @Override + public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltip, TooltipFlag pFlag) { + super.appendHoverText(pStack, pLevel, pTooltip, pFlag); + int power = getPowerFromNBT(pStack) * 2 + 1; + int fortune = getFortuneFromNBT(pStack); + pTooltip.add(Component.literal(power+"x"+power).withStyle(ChatFormatting.GRAY)); + MutableComponent texts = Component.translatable(Enchantments.BLOCK_FORTUNE.getDescriptionId()); + texts.append(Component.literal(" "+fortune)); + pTooltip.add(texts.withStyle(ChatFormatting.GRAY)); + } +} diff --git a/src/main/resources/assets/frostedheart/blockstates/biogas_digester_controller.json b/src/main/resources/assets/frostedheart/blockstates/biogas_digester_controller.json new file mode 100644 index 000000000..143c7a94a --- /dev/null +++ b/src/main/resources/assets/frostedheart/blockstates/biogas_digester_controller.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "frostedheart:block/biogas_digester_controller" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/blockstates/biogas_digester_io.json b/src/main/resources/assets/frostedheart/blockstates/biogas_digester_io.json new file mode 100644 index 000000000..cb26dac7f --- /dev/null +++ b/src/main/resources/assets/frostedheart/blockstates/biogas_digester_io.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "frostedheart:block/biogas_digester_io" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/blockstates/gunpowder_barrel.json b/src/main/resources/assets/frostedheart/blockstates/gunpowder_barrel.json new file mode 100644 index 000000000..7de06157c --- /dev/null +++ b/src/main/resources/assets/frostedheart/blockstates/gunpowder_barrel.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "frostedheart:block/gunpowder_barrel" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/lang/en_us/en_us.json b/src/main/resources/assets/frostedheart/lang/en_us/en_us.json index 4f1b821f7..fbd23ca73 100644 --- a/src/main/resources/assets/frostedheart/lang/en_us/en_us.json +++ b/src/main/resources/assets/frostedheart/lang/en_us/en_us.json @@ -343,5 +343,10 @@ "gui.frostedheart.wheel_menu.message": "Move the mouse to select, release [%s] to execute", "gui.frostedheart.wheel_menu.selection.nutrition": "Health Info", "gui.frostedheart.wheel_menu.selection.clothing": "View Clothing", - "gui.frostedheart.wheel_menu.selection.debug": "Open Debug Menu" + "gui.frostedheart.wheel_menu.selection.debug": "Open Debug Menu", + "gui.frostedheart.biogas_digester_controller_menu.size": "Size", + "gui.frostedheart.biogas_digester_controller_menu.gas_value": "Gas Value", + "gui.frostedheart.biogas_digester_controller_menu.max_gas_value": "Max Gas Value", + "gui.frostedheart.biogas_digester_controller_menu.unavailable": "Unavailable", + "block.frostedheart.gunpowder_barrel": "Gunpowder Barrel" } \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/lang/zh_cn/zh_cn.json b/src/main/resources/assets/frostedheart/lang/zh_cn/zh_cn.json index a707dc1e4..d0a7d19ae 100644 --- a/src/main/resources/assets/frostedheart/lang/zh_cn/zh_cn.json +++ b/src/main/resources/assets/frostedheart/lang/zh_cn/zh_cn.json @@ -870,5 +870,10 @@ "gui.frostedheart.trade.profession.frostedheart:hunter": "林地猎人", "gui.frostedheart.trade.profession.frostedheart:ocean_hunter": "海洋猎人", "gui.frostedheart.trade.profession.frostedheart:miner": "矿工", - "gui.frostedheart.trade.profession.frostedheart:explorer": "探险家" + "gui.frostedheart.trade.profession.frostedheart:explorer": "探险家", + "gui.frostedheart.biogas_digester_controller_menu.size": "容积", + "gui.frostedheart.biogas_digester_controller_menu.gas_value": "当前储气量", + "gui.frostedheart.biogas_digester_controller_menu.max_gas_value": "最大储气量", + "gui.frostedheart.biogas_digester_controller_menu.unavailable": "不可用", + "block.frostedheart.gunpowder_barrel": "炸药桶" } \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/models/block/biogas_digester_controller.json b/src/main/resources/assets/frostedheart/models/block/biogas_digester_controller.json new file mode 100644 index 000000000..37bce3cef --- /dev/null +++ b/src/main/resources/assets/frostedheart/models/block/biogas_digester_controller.json @@ -0,0 +1,53 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 64], + "textures": { + "0": "frostedheart:block/biogas_digester_controller", + "particle": "frostedheart:block/biogas_digester_controller" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 4, 4], "texture": "#0"}, + "east": {"uv": [0, 4, 4, 8], "texture": "#0"}, + "south": {"uv": [4, 0, 8, 4], "texture": "#0"}, + "west": {"uv": [4, 4, 8, 8], "texture": "#0"}, + "up": {"uv": [4, 12, 0, 8], "texture": "#0"}, + "down": {"uv": [12, 0, 8, 4], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/models/block/biogas_digester_io.json b/src/main/resources/assets/frostedheart/models/block/biogas_digester_io.json new file mode 100644 index 000000000..5a679e5a7 --- /dev/null +++ b/src/main/resources/assets/frostedheart/models/block/biogas_digester_io.json @@ -0,0 +1,104 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 64], + "textures": { + "0": "frostedheart:block/biogas_digester_io", + "particle": "frostedheart:block/biogas_digester_io" + }, + "elements": [ + { + "from": [2, 0, 2], + "to": [14, 16, 14], + "faces": { + "north": {"uv": [0, 0, 3, 4], "texture": "#0"}, + "east": {"uv": [3, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [0, 4, 3, 8], "texture": "#0"}, + "west": {"uv": [3, 4, 6, 8], "texture": "#0"}, + "up": {"uv": [10.5, 3.5, 7, 0], "texture": "#0"}, + "down": {"uv": [10.5, 3.5, 7.5, 6.5], "texture": "#0"} + } + }, + { + "from": [0, 0, 6], + "to": [2, 2, 10], + "faces": { + "north": {"uv": [5, 8, 5.5, 8.5], "texture": "#0"}, + "east": {"uv": [6, 6, 7, 6.5], "texture": "#0"}, + "south": {"uv": [4.5, 8, 5, 8.5], "texture": "#0"}, + "west": {"uv": [6, 6.5, 7, 7], "texture": "#0"}, + "up": {"uv": [1, 9.75, 0, 8.25], "texture": "#0"}, + "down": {"uv": [10, 6.5, 9.5, 7.5], "texture": "#0"} + } + }, + { + "from": [6, 0, 0], + "to": [10, 2, 2], + "faces": { + "north": {"uv": [9.5, 7.75, 10.5, 8.25], "texture": "#0"}, + "east": {"uv": [8.5, 7.75, 9, 8.25], "texture": "#0"}, + "south": {"uv": [8.5, 9.25, 9.5, 9.75], "texture": "#0"}, + "west": {"uv": [9, 7.75, 9.5, 8.25], "texture": "#0"}, + "up": {"uv": [10.5, 9.25, 9, 8.25], "texture": "#0"}, + "down": {"uv": [10.5, 9.25, 9.5, 9.75], "texture": "#0"} + } + }, + { + "from": [14, 0, 6], + "to": [16, 2, 10], + "faces": { + "north": {"uv": [2, 9, 2.5, 9.5], "texture": "#0"}, + "east": {"uv": [7.5, 7, 8.5, 7.5], "texture": "#0"}, + "south": {"uv": [7.5, 8, 8, 8.5], "texture": "#0"}, + "west": {"uv": [7.5, 7.5, 8.5, 8], "texture": "#0"}, + "up": {"uv": [2, 9.5, 1, 8], "texture": "#0"}, + "down": {"uv": [3.5, 8.5, 3, 9.5], "texture": "#0"} + } + }, + { + "from": [6, 0, 14], + "to": [10, 2, 16], + "faces": { + "north": {"uv": [5.75, 8.25, 6.75, 8.75], "texture": "#0"}, + "east": {"uv": [6.75, 8.25, 7.25, 8.75], "texture": "#0"}, + "south": {"uv": [7.25, 8.75, 8.25, 9.25], "texture": "#0"}, + "west": {"uv": [8.25, 8.75, 8.75, 9.25], "texture": "#0"}, + "up": {"uv": [7.25, 9.75, 5.75, 8.75], "texture": "#0"}, + "down": {"uv": [8.25, 9.25, 7.25, 9.75], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "head": { + "translation": [0, 14.25, 0] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/models/block/gunpowder_barrel.json b/src/main/resources/assets/frostedheart/models/block/gunpowder_barrel.json new file mode 100644 index 000000000..85f39ff54 --- /dev/null +++ b/src/main/resources/assets/frostedheart/models/block/gunpowder_barrel.json @@ -0,0 +1,56 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "1": "frostedheart:block/gunpowder_barrel", + "particle": "frostedheart:block/gunpowder_barrel" + }, + "elements": [ + { + "from": [2, 0, 2], + "to": [14, 16, 14], + "faces": { + "north": {"uv": [0, 0, 6, 8], "texture": "#1"}, + "east": {"uv": [0, 0, 6, 8], "texture": "#1"}, + "south": {"uv": [0, 0, 6, 8], "texture": "#1"}, + "west": {"uv": [0, 0, 6, 8], "texture": "#1"}, + "up": {"uv": [0, 8, 6, 14], "texture": "#1", "cullface": "up"}, + "down": {"uv": [6, 8, 12, 14], "texture": "#1", "cullface": "down"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "head": { + "translation": [0, 14.25, 0] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/models/item/gunpowder_barrel.json b/src/main/resources/assets/frostedheart/models/item/gunpowder_barrel.json new file mode 100644 index 000000000..9d41fde17 --- /dev/null +++ b/src/main/resources/assets/frostedheart/models/item/gunpowder_barrel.json @@ -0,0 +1,3 @@ +{ + "parent": "frostedheart:block/gunpowder_barrel" +} \ No newline at end of file diff --git a/src/main/resources/assets/frostedheart/textures/block/biogas_digester_controller.png b/src/main/resources/assets/frostedheart/textures/block/biogas_digester_controller.png new file mode 100644 index 000000000..9f0429765 Binary files /dev/null and b/src/main/resources/assets/frostedheart/textures/block/biogas_digester_controller.png differ diff --git a/src/main/resources/assets/frostedheart/textures/block/biogas_digester_io.png b/src/main/resources/assets/frostedheart/textures/block/biogas_digester_io.png new file mode 100644 index 000000000..86ba21e33 Binary files /dev/null and b/src/main/resources/assets/frostedheart/textures/block/biogas_digester_io.png differ diff --git a/src/main/resources/assets/frostedheart/textures/block/gunpowder_barrel.png b/src/main/resources/assets/frostedheart/textures/block/gunpowder_barrel.png new file mode 100644 index 000000000..989f464a8 Binary files /dev/null and b/src/main/resources/assets/frostedheart/textures/block/gunpowder_barrel.png differ diff --git a/src/main/resources/assets/frostedheart/textures/gui/biogas_digester_controller_gui.png b/src/main/resources/assets/frostedheart/textures/gui/biogas_digester_controller_gui.png new file mode 100644 index 000000000..c6204c934 Binary files /dev/null and b/src/main/resources/assets/frostedheart/textures/gui/biogas_digester_controller_gui.png differ diff --git a/src/main/resources/assets/frostedheart/textures/gui/biogas_digester_io_gui.png b/src/main/resources/assets/frostedheart/textures/gui/biogas_digester_io_gui.png new file mode 100644 index 000000000..9885c68b7 Binary files /dev/null and b/src/main/resources/assets/frostedheart/textures/gui/biogas_digester_io_gui.png differ