diff --git a/build.gradle b/build.gradle index 66c2d5b..2c5f58a 100644 --- a/build.gradle +++ b/build.gradle @@ -50,15 +50,11 @@ repositories { } dependencies { - //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. - // You may need to force-disable transitiveness on them. modImplementation(include("io.github.cottonmc:LibGui:${project.libgui_version}")) modImplementation( include("com.jamieswhiteshirt:reach-entity-attributes:${project.reach_version}")) diff --git a/gradle.properties b/gradle.properties index 6331957..384dbd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,12 +8,12 @@ org.gradle.jvmargs=-Xmx4G loader_version=0.11.1 # Mod Properties - mod_version = ALPHA.4 + mod_version = ALPHA.5 maven_group = azzy.ttlg archives_base_name = TTLG libgui_version = 3.3.3+1.16.5 - patchouli_version = 1.16.4-48-FABRIC-SNAPSHOT - ftl_version=0.1.4 + patchouli_version = 1.16.4-50-FABRIC + ftl_version=0.2.2 reach_version = 1.0.1 diff --git a/src/main/java/azzy/fabric/lookingglass/block/NebulousHaliteBlock.java b/src/main/java/azzy/fabric/lookingglass/block/NebulousHaliteBlock.java index 2155e47..6e4bcd7 100644 --- a/src/main/java/azzy/fabric/lookingglass/block/NebulousHaliteBlock.java +++ b/src/main/java/azzy/fabric/lookingglass/block/NebulousHaliteBlock.java @@ -41,7 +41,7 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit if(!world.isClient()) { if(!(entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) { Random random = world.getRandom(); - if(entity.isLiving() && random.nextInt(51) == 0) { + if(random.nextInt(51) == 0) { if(random.nextBoolean()) { ((LivingEntity) entity).applyStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 10 + random.nextInt(20), 39, false, false, false)); } diff --git a/src/main/java/azzy/fabric/lookingglass/block/NebulousSaltBlock.java b/src/main/java/azzy/fabric/lookingglass/block/NebulousSaltBlock.java index ee210d0..bcc0d8c 100644 --- a/src/main/java/azzy/fabric/lookingglass/block/NebulousSaltBlock.java +++ b/src/main/java/azzy/fabric/lookingglass/block/NebulousSaltBlock.java @@ -62,7 +62,7 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit if(!world.isClient()) { if(!(entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) { Random random = world.getRandom(); - if(entity.isLiving() && random.nextInt(101) == 0) { + if(random.nextInt(101) == 0) { if(random.nextBoolean()) { ((LivingEntity) entity).applyStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 10 + random.nextInt(20), 39, false, false, false)); } diff --git a/src/main/java/azzy/fabric/lookingglass/block/TTLGBlocks.java b/src/main/java/azzy/fabric/lookingglass/block/TTLGBlocks.java index ab3ff58..624d926 100644 --- a/src/main/java/azzy/fabric/lookingglass/block/TTLGBlocks.java +++ b/src/main/java/azzy/fabric/lookingglass/block/TTLGBlocks.java @@ -19,6 +19,7 @@ import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import net.minecraft.util.registry.Registry; @@ -96,6 +97,7 @@ private static FabricBlockSettings eldenMachine() { public static final Block WHITESTONE_TILE = registerGeneratedBlock("whitestone_tile", new Block(FabricBlockSettings.copyOf(WHITESTONE_BLOCK)), null, null, basicMachineItem(), SingletType.BLOCK); public static final Block[] WHITESTONE_BRICK_SET = registerBuildingBlocks("whitestone_bricks", FabricBlockSettings.copyOf(WHITESTONE_BLOCK), basicMachineItem(), WHISTONE_POLISHED[0].asItem(), false); public static final Block[] WHITESTONE_LARGE_BRICK_SET = registerBuildingBlocks("large_whitestone_bricks", FabricBlockSettings.copyOf(WHITESTONE_BLOCK), basicMachineItem(), WHITESTONE_TILE.asItem(), false); + public static final Block DWARVEN_STONE = registerGeneratedBlock("dwarven_stone", new Block(FabricBlockSettings.copyOf(Blocks.STONE).resistance(500).materialColor(DyeColor.GRAY).sounds(BlockSoundGroup.NETHER_BRICKS)), null, null, basicMachineItem(), SingletType.BLOCK); public static final Block[] BASALT_BRICK_SET = registerBuildingBlocks("basalt_bricks", FabricBlockSettings.copyOf(Blocks.POLISHED_BASALT), basicMachineItem(), Items.POLISHED_BASALT, false); public static final Block HERRINGBONE_OAK_PLANKS = registerBlock("herringbone_oak_planks", new HerringboneWoodBlock(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS)), basicMachineItem()); diff --git a/src/main/java/azzy/fabric/lookingglass/blockentity/BasePipeEntity.java b/src/main/java/azzy/fabric/lookingglass/blockentity/BasePipeEntity.java index d0b9bc9..f34a8cd 100644 --- a/src/main/java/azzy/fabric/lookingglass/blockentity/BasePipeEntity.java +++ b/src/main/java/azzy/fabric/lookingglass/blockentity/BasePipeEntity.java @@ -6,7 +6,7 @@ import dev.technici4n.fasttransferlib.api.fluid.FluidApi; import dev.technici4n.fasttransferlib.api.fluid.FluidIo; import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable; -import net.fabricmc.fabric.api.provider.v1.block.BlockApiLookup; +import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; @@ -18,14 +18,16 @@ public abstract class BasePipeEntity extends BlockEntity implements Tickable, BlockEntityClientSerializable, RedstoneReactiveEntity { + private final BlockApiLookup lookup; + private final boolean strict; protected final int offset = LookingGlassCommon.RANDOM.nextInt(10); protected boolean straight = false; protected final Set IO = new HashSet<>(); - private final BlockApiLookup lookup; - public BasePipeEntity(BlockEntityType type, BlockApiLookup lookup) { + public BasePipeEntity(BlockEntityType type, BlockApiLookup lookup, boolean strict) { super(type); this.lookup = lookup; + this.strict = strict; } @Override @@ -44,18 +46,39 @@ public void tick() { public Set checkConnections() { Set ioSet = new HashSet<>(); for(Direction direction : Direction.values()){ - T io = lookup.get(world, pos.offset(direction), direction.getOpposite()); - if(io != null){ - if(!getCachedState().get(PipeBlock.getFACING().get(direction))) { - world.setBlockState(pos, world.getBlockState(pos).with(PipeBlock.getFACING().get(direction), true)); - IO.add(direction); + BlockEntity entity = world.getBlockEntity(pos.offset(direction)); + if(entity instanceof BasePipeEntity && strict) { + if(entity != null) { + BlockEntityType type = entity.getType(); + if (type == getType()) { + T io = lookup.get(world, pos.offset(direction), direction.getOpposite()); + if (io != null) { + if (!getCachedState().get(PipeBlock.getFACING().get(direction))) { + world.setBlockState(pos, world.getBlockState(pos).with(PipeBlock.getFACING().get(direction), true)); + IO.add(direction); + } + ioSet.add(io); + continue; + } + } } - ioSet.add(io); - } - else { world.setBlockState(pos, world.getBlockState(pos).with(PipeBlock.getFACING().get(direction), false)); getIO().remove(direction); } + else { + T io = lookup.get(world, pos.offset(direction), direction.getOpposite()); + if(io != null){ + if(!getCachedState().get(PipeBlock.getFACING().get(direction))) { + world.setBlockState(pos, world.getBlockState(pos).with(PipeBlock.getFACING().get(direction), true)); + IO.add(direction); + } + ioSet.add(io); + } + else { + world.setBlockState(pos, world.getBlockState(pos).with(PipeBlock.getFACING().get(direction), false)); + getIO().remove(direction); + } + } } return ioSet; } diff --git a/src/main/java/azzy/fabric/lookingglass/blockentity/PowerPipeEntity.java b/src/main/java/azzy/fabric/lookingglass/blockentity/PowerPipeEntity.java index ba0d132..4501a6c 100644 --- a/src/main/java/azzy/fabric/lookingglass/blockentity/PowerPipeEntity.java +++ b/src/main/java/azzy/fabric/lookingglass/blockentity/PowerPipeEntity.java @@ -16,22 +16,18 @@ public class PowerPipeEntity extends BasePipeEntity implements EnergyI private final double maxPower, transferRate; private double power; + private boolean ticked; public PowerPipeEntity(BlockEntityType type, double transferRate) { - super(type, EnergyApi.SIDED); + super(type, EnergyApi.SIDED, true); this.maxPower = transferRate * 4.0; this.transferRate = transferRate; } @Override public void performTransfers(Set participants) { - List cables = new ArrayList<>(); - cables.add(this); for (EnergyIo energyIo : participants.toArray(new EnergyIo[0])) { if(energyIo instanceof PowerPipeEntity) { - if(((PowerPipeEntity) energyIo).getType() == getType()) { - cables.add((PowerPipeEntity) energyIo); - } continue; } if(power > 0 && energyIo.supportsInsertion()) { @@ -50,7 +46,13 @@ else if (energyIo.getEnergy() > 0 && energyIo.supportsExtraction()) { } } - //Taken from Techreborn's CableBlockEntity + //Taken from Techreborn's CableBlockEntity, some of it at least + + List cables = new ArrayList<>(); + + if(!ticked) { + cables.addAll(getNeighbours()); + } if(cables.size() > 1) { double totalPower = cables.stream().mapToDouble(EnergyIo::getEnergy).sum(); @@ -63,6 +65,8 @@ else if (energyIo.getEnergy() > 0 && energyIo.supportsExtraction()) { if(!world.isClient()) { sync(); } + + ticked = false; } public Set getNeighbours() { @@ -78,9 +82,10 @@ public Set getNeighbours() { public void getNeighbours(Set neighbours) { neighbours.add(this); + this.ticked = true; Arrays.stream(Direction.values()) .map(direction -> world.getBlockEntity(pos.offset(direction))) - .filter(blockEntity -> blockEntity.getType() == getType()) + .filter(blockEntity -> blockEntity != null && blockEntity.getType() == getType()) .forEach(entity -> { if(!neighbours.contains(entity)) ((PowerPipeEntity)entity).getNeighbours(neighbours); @@ -147,7 +152,7 @@ public CompoundTag toTag(CompoundTag tag) { @Override public void fromTag(BlockState state, CompoundTag tag) { - power = tag.getDouble("energy"); + power = tag.getDouble("power"); super.fromTag(state, tag); } diff --git a/src/main/java/azzy/fabric/lookingglass/item/EnergyProbeItem.java b/src/main/java/azzy/fabric/lookingglass/item/EnergyProbeItem.java index 8b56b01..195a1f5 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/EnergyProbeItem.java +++ b/src/main/java/azzy/fabric/lookingglass/item/EnergyProbeItem.java @@ -9,6 +9,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import java.math.BigDecimal; +import java.text.DecimalFormat; + public class EnergyProbeItem extends Item { public EnergyProbeItem(Settings settings) { @@ -20,8 +23,10 @@ public ActionResult useOnBlock(ItemUsageContext context) { World world = context.getWorld(); EnergyIo io = EnergyApi.SIDED.get(world, context.getBlockPos(), context.getSide()); if(io != null) { - if(!world.isClient()) - context.getPlayer().sendMessage(new LiteralText(io.getEnergy() + "Lu"), true); + if(!world.isClient()) { + double energy = io.getEnergy(); + context.getPlayer().sendMessage(new LiteralText((Double.isFinite(energy) ? Math.ceil(energy) : energy) + " Lu"), true); + } return ActionResult.SUCCESS; } return super.useOnBlock(context); diff --git a/src/main/java/azzy/fabric/lookingglass/item/TTLGItems.java b/src/main/java/azzy/fabric/lookingglass/item/TTLGItems.java index 057fec2..6b1e75b 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/TTLGItems.java +++ b/src/main/java/azzy/fabric/lookingglass/item/TTLGItems.java @@ -1,5 +1,6 @@ package azzy.fabric.lookingglass.item; +import azzy.fabric.lookingglass.util.datagen.ModelJsonGen; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; @@ -38,12 +39,20 @@ private static FabricItemSettings eldenmetalSettings() { public static final Item PRISMATIC_SHIMMERFIN = registerItem("shimmerfin", new FishWeaponItem(true, 199, defaultSettings().rarity(Rarity.EPIC).fireproof().food(shimmerfin))); //Materials + public static final Item FISH_FEED = registerItem("fish_feed", new Item(defaultSettings().food(badNoms))); + public static final Item DWARVEN_CLAY = registerGeneratedItem("dwarven_clay", new Item(defaultSettings())); public static final Item ELDENMETAL_NUGGET = registerItem("eldenmetal_drop", new Item(eldenmetalSettings())); public static final Item ELDENMETAL_INGOT = registerItem("eldenmetal_tear", new Item(eldenmetalSettings())); public static final Item ELDENMETAL_GEMSTONE = registerItem("eldenmetal_gem", new Item(eldenmetalSettings())); - public static final Item FISH_FEED = registerItem("fish_feed", new Item(defaultSettings().food(badNoms))); private static Item registerItem(String name, Item item) { return Registry.register(Registry.ITEM, new Identifier(MODID, name), item); } + + private static Item registerGeneratedItem(String name, Item item) { + Identifier id = new Identifier(MODID, name); + if(REGEN_ITEMS) + ModelJsonGen.genItemJson(METADATA, id); + return Registry.register(Registry.ITEM, id, item); + } } diff --git a/src/main/java/azzy/fabric/lookingglass/util/datagen/ModelJsonGen.java b/src/main/java/azzy/fabric/lookingglass/util/datagen/ModelJsonGen.java index 0c62775..6153c40 100644 --- a/src/main/java/azzy/fabric/lookingglass/util/datagen/ModelJsonGen.java +++ b/src/main/java/azzy/fabric/lookingglass/util/datagen/ModelJsonGen.java @@ -9,6 +9,21 @@ public class ModelJsonGen { + public static void genItemJson(Metadata metadata, Identifier name) { + String item = "{\n" + + " \"parent\": \"item/generated\",\n" + + " \"textures\": {\n" + + " \"layer0\": \"" + name.getNamespace() + ":item/" + name.getPath() + "\"\n" + + " }\n" + + "}"; + + try { + FileUtils.writeStringToFile(metadata.genResourceJson(name.getPath(), "", Metadata.ResourceType.ITEM_MODEL), item, Charsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + } + public static void genBlockJson(Metadata metadata, Identifier texId, Identifier name, String path) { String block = "{\n" + " \"parent\": \"minecraft:block/cube_all\",\n" + diff --git a/src/main/resources/assets/lookingglass/blockstates/dwarven_stone.json b/src/main/resources/assets/lookingglass/blockstates/dwarven_stone.json new file mode 100644 index 0000000..2af9c68 --- /dev/null +++ b/src/main/resources/assets/lookingglass/blockstates/dwarven_stone.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "lookingglass:block/dwarven_stone" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lookingglass/models/block/dwarven_stone.json b/src/main/resources/assets/lookingglass/models/block/dwarven_stone.json new file mode 100644 index 0000000..80e2cb3 --- /dev/null +++ b/src/main/resources/assets/lookingglass/models/block/dwarven_stone.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "lookingglass:block/dwarven_stone" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lookingglass/models/item/dwarven_clay.json b/src/main/resources/assets/lookingglass/models/item/dwarven_clay.json new file mode 100644 index 0000000..6077060 --- /dev/null +++ b/src/main/resources/assets/lookingglass/models/item/dwarven_clay.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "lookingglass:item/dwarven_clay" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lookingglass/models/item/dwarven_stone.json b/src/main/resources/assets/lookingglass/models/item/dwarven_stone.json new file mode 100644 index 0000000..aa8c35c --- /dev/null +++ b/src/main/resources/assets/lookingglass/models/item/dwarven_stone.json @@ -0,0 +1,3 @@ +{ + "parent": "lookingglass:block/dwarven_stone" +} \ No newline at end of file diff --git a/src/main/resources/assets/lookingglass/textures/block/dwarven_stone.png b/src/main/resources/assets/lookingglass/textures/block/dwarven_stone.png new file mode 100755 index 0000000..26f9e84 Binary files /dev/null and b/src/main/resources/assets/lookingglass/textures/block/dwarven_stone.png differ diff --git a/src/main/resources/assets/lookingglass/textures/item/dwarven_clay.png b/src/main/resources/assets/lookingglass/textures/item/dwarven_clay.png new file mode 100755 index 0000000..9eb2087 Binary files /dev/null and b/src/main/resources/assets/lookingglass/textures/item/dwarven_clay.png differ diff --git a/src/main/resources/data/lookingglass/loot_tables/blocks/dwarven_stone.json b/src/main/resources/data/lookingglass/loot_tables/blocks/dwarven_stone.json new file mode 100644 index 0000000..fb9831d --- /dev/null +++ b/src/main/resources/data/lookingglass/loot_tables/blocks/dwarven_stone.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "lookingglass:dwarven_stone" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 75aa9ee..4e7acae 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "lookingglass", "version": "2.0.0-alpha.4", - "name": "Through the Looking Glass", + "name": "Through The Looking Glass", "description": "Not a mod about glass working", "authors": [ "Azazelthedemonlord"