commit 8d8638c457101f633dac1aea41208e4ae785c0af parent ead65b77e6ef22dfd43635d3e56c491d040c4e52 Author: Ambos <51835548+Amb0s@users.noreply.github.com> Date: Sat, 27 Jan 2024 20:58:01 +0100 Merge pull request #21 Updated to BTA 7.1a Diffstat:
17 files changed, 268 insertions(+), 111 deletions(-)
diff --git a/gradle.properties b/gradle.properties @@ -1,15 +1,14 @@ org.gradle.jvmargs=-Xmx2G # BTA -bta_version=1.7.7.0_02 +bta_version=7.1-pre1a # Loader -loader_version=0.14.19-babric.1-bta +loader_version=0.14.19-babric.3-bta # HalpLibe -halplibe_version=2.5.0 - +halplibe_version=3.1.1 # Mod -mod_version=0.2.0 +mod_version=0.2.1-7.1 mod_group=turniplabs -mod_name=simple-tech +mod_name=simple-tech-useless diff --git a/src/main/java/turniplabs/simpletech/SimpleTech.java b/src/main/java/turniplabs/simpletech/SimpleTech.java @@ -1,27 +1,29 @@ package turniplabs.simpletech; -import net.fabricmc.api.ModInitializer; import net.minecraft.client.sound.block.BlockSounds; import net.minecraft.core.block.Block; import net.minecraft.core.block.material.Material; import net.minecraft.core.block.tag.BlockTags; -import net.minecraft.core.item.Item; import net.minecraft.core.util.helper.Direction; import net.minecraft.core.world.World; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import turniplabs.halplibe.helper.BlockBuilder; import turniplabs.halplibe.helper.EntityHelper; -import turniplabs.halplibe.helper.RecipeHelper; -import turniplabs.halplibe.util.ConfigUpdater; +import turniplabs.halplibe.util.GameStartEntrypoint; import turniplabs.halplibe.util.TomlConfigHandler; import turniplabs.halplibe.util.toml.Toml; -import turniplabs.simpletech.block.*; +import turniplabs.simpletech.block.BlockAllocator; +import turniplabs.simpletech.block.BlockFan; +import turniplabs.simpletech.block.BlockJumpPad; +import turniplabs.simpletech.block.BlockLightSensor; +import turniplabs.simpletech.block.BlockRedstoneNotGate; +import turniplabs.simpletech.block.BlockTrappedChest; import turniplabs.simpletech.block.entity.TileEntityAllocator; import turniplabs.simpletech.block.entity.TileEntityFan; import turniplabs.simpletech.block.entity.TileEntityLightSensor; -public class SimpleTech implements ModInitializer { +public class SimpleTech implements GameStartEntrypoint { public static final String MOD_ID = "simpletech"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public static final TomlConfigHandler config; @@ -50,10 +52,8 @@ public class SimpleTech implements ModInitializer { configToml.addEntry("Settings.FAN_RANGE", 4); configToml.addCategory("GUI"); configToml.addEntry("GUI.ALLOCATOR_GUI_ID", 13); - ConfigUpdater stupidDesignDecision = new ConfigUpdater() {public void update() {}}; - - config = new TomlConfigHandler(stupidDesignDecision, MOD_ID, configToml); + config = new TomlConfigHandler(MOD_ID, configToml); FAN_RANGE = config.getInt("Settings.FAN_RANGE"); UNPOWERED_FAN_ID = config.getInt("BlockIDs.UNPOWERED_FAN_ID"); POWERED_FAN_ID = config.getInt("BlockIDs.POWERED_FAN_ID"); @@ -107,6 +107,7 @@ public class SimpleTech implements ModInitializer { .setHardness(2.5f) .setResistance(5.0f) .setTags(BlockTags.MINEABLE_BY_AXE, BlockTags.FENCES_CONNECT) + .setTickOnLoad() .build(new BlockTrappedChest("chest.trapped", TRAPPED_CHEST_ID, Material.wood)); public static final Block lightSensor = woodenBlockBuilder .setTextures("light_sensor.png") @@ -137,45 +138,17 @@ public class SimpleTech implements ModInitializer { .build(new BlockRedstoneNotGate("not.gate.active", NOT_GATE_ACTIVE_ID, Material.stone, true)); @Override - public void onInitialize() { + public void beforeGameStart() { // Entities. - EntityHelper.createTileEntity(TileEntityFan.class, "Fan"); - EntityHelper.createTileEntity(TileEntityLightSensor.class, "Light Sensor"); - EntityHelper.createTileEntity(TileEntityAllocator.class, "Allocator"); + EntityHelper.Core.createTileEntity(TileEntityFan.class, "Fan"); + EntityHelper.Core.createTileEntity(TileEntityLightSensor.class, "Light Sensor"); + EntityHelper.Core.createTileEntity(TileEntityAllocator.class, "Allocator"); + LOGGER.info("Simple Tech initialized."); + } - // Recipes. - RecipeHelper.Crafting.createRecipe(unpoweredFan, 1, new Object[]{ - "CCC", - "CIC", - "CRC", - 'C', Block.cobbleStone, - 'I', Item.ingotIron, - 'R', Item.dustRedstone - }); - RecipeHelper.Crafting.createShapelessRecipe(jumpPad, 1, new Object[]{ - Item.slimeball, Block.slabPlanksOak - }); - RecipeHelper.Crafting.createShapelessRecipe(trappedChest, 1, new Object[]{ - Item.dustRedstone, Block.chestPlanksOak - }); - RecipeHelper.Crafting.createRecipe(lightSensor, 1, new Object[]{ - " G ", - " Q ", - " S ", - 'G', Block.glass, - 'Q', Item.quartz, - 'S', Block.slabPlanksOak - }); - RecipeHelper.Crafting.createRecipe(allocator, 1, new Object[]{ - "CRC", - "CGC", - "CRC", - 'C', Block.cobbleStone, - 'R', Item.dustRedstone, - 'G', Item.ingotGold, - }); + @Override + public void afterGameStart() { - LOGGER.info("Simple Tech initialized."); } public static int setBit(int number, int position, int bit) { diff --git a/src/main/java/turniplabs/simpletech/SimpleTechRecipes.java b/src/main/java/turniplabs/simpletech/SimpleTechRecipes.java @@ -0,0 +1,22 @@ +package turniplabs.simpletech; + +import net.minecraft.core.block.Block; +import net.minecraft.core.data.DataLoader; +import net.minecraft.core.data.registry.Registries; +import net.minecraft.core.data.registry.recipe.RecipeGroup; +import net.minecraft.core.data.registry.recipe.RecipeNamespace; +import net.minecraft.core.data.registry.recipe.RecipeSymbol; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCrafting; +import net.minecraft.core.item.ItemStack; +import turniplabs.halplibe.util.RecipeEntrypoint; + +public class SimpleTechRecipes implements RecipeEntrypoint { + public static final RecipeNamespace SIMPLE_TECH = new RecipeNamespace(); + public static final RecipeGroup<RecipeEntryCrafting<?, ?>> WORKBENCH = new RecipeGroup<>(new RecipeSymbol(new ItemStack(Block.workbench))); + @Override + public void onRecipesReady() { + SIMPLE_TECH.register("workbench", WORKBENCH); + Registries.RECIPES.register("simpletech", SIMPLE_TECH); + DataLoader.loadRecipes("/assets/simpletech/recipes/workbench.json"); + } +} diff --git a/src/main/java/turniplabs/simpletech/block/BlockAllocator.java b/src/main/java/turniplabs/simpletech/block/BlockAllocator.java @@ -143,7 +143,7 @@ public class BlockAllocator extends BlockTileEntity { protected boolean blockingCubeAtPos(World world, int x, int y, int z) { int blockID = world.getBlockId(x, y, z); - boolean isOpaque = Block.opaqueCubeLookup[blockID]; + boolean isOpaque = Block.translucent[blockID]; return isOpaque || blockID == Block.glass.id || blockID == Block.cactus.id || @@ -208,7 +208,7 @@ public class BlockAllocator extends BlockTileEntity { List<Entity> index = world.getEntitiesWithinAABB(IInventory.class, AABB.getBoundingBoxFromPool( x + dx, y + dy, z + dz, x + dx + 1, y + dy + 1, z + dz + 1)); - if (index.size() > 0 && (!(index.get(0) instanceof EntityMinecart) || + if (!index.isEmpty() && (!(index.get(0) instanceof EntityMinecart) || ((EntityMinecart) index.get(0)).minecartType == 1)) { outputContainer = (IInventory) index.get(0); } @@ -277,7 +277,7 @@ public class BlockAllocator extends BlockTileEntity { entities = world.getEntitiesWithinAABB(IInventory.class, AABB.getBoundingBoxFromPool( x - dx, y - dy, z - dz, x - dx + 1, y - dy + 1, z - dz + 1)); - if (entities.size() > 0 && (!(entities.get(0) instanceof EntityMinecart) || + if (!entities.isEmpty() && (!(entities.get(0) instanceof EntityMinecart) || ((EntityMinecart)entities.get(0)).minecartType == 1)) { inputContainer = (IInventory) entities.get(0); } diff --git a/src/main/java/turniplabs/simpletech/block/BlockJumpPad.java b/src/main/java/turniplabs/simpletech/block/BlockJumpPad.java @@ -13,7 +13,7 @@ public class BlockJumpPad extends Block { } @Override - public boolean isOpaqueCube() { + public boolean isSolidRender() { return false; } diff --git a/src/main/java/turniplabs/simpletech/block/BlockLightSensor.java b/src/main/java/turniplabs/simpletech/block/BlockLightSensor.java @@ -27,7 +27,7 @@ public class BlockLightSensor extends BlockTileEntity { } @Override - public boolean isOpaqueCube() { + public boolean isSolidRender() { return false; } diff --git a/src/main/java/turniplabs/simpletech/block/BlockRedstoneNotGate.java b/src/main/java/turniplabs/simpletech/block/BlockRedstoneNotGate.java @@ -32,7 +32,7 @@ public class BlockRedstoneNotGate extends Block { } @Override - public boolean isOpaqueCube() { + public boolean isSolidRender() { return false; } @@ -40,7 +40,7 @@ public class BlockRedstoneNotGate extends Block { public boolean renderAsNormalBlock() { return false; } - + @Override public void updateTick(World world, int x, int y, int z, Random rand) { int l = world.getBlockMetadata(x, y, z); boolean isPowering = this.unknown(world, x, y, z, l); @@ -50,7 +50,7 @@ public class BlockRedstoneNotGate extends Block { world.setBlockAndMetadataWithNotify(x, y, z, SimpleTech.notGateActive.id, l); } } - + @Override public int getBlockTextureFromSideAndMetadata(Side side, int j) { if (side == Side.BOTTOM) { return !this.isPowered ? texCoordToIndex(3, 7) : texCoordToIndex(3, 6); @@ -60,15 +60,15 @@ public class BlockRedstoneNotGate extends Block { return texCoordToIndex(5, 0); } } - + @Override public boolean shouldSideBeRendered(WorldSource blockAccess, int x, int y, int z, int side) { return side != 0 && side != 1; } - + @Override public boolean isIndirectlyPoweringTo(World world, int x, int y, int z, int side) { return this.isPoweringTo(world, x, y, z, side); } - + @Override public boolean isPoweringTo(WorldSource blockAccess, int x, int y, int z, int side) { if (!this.isPowered) { return true; @@ -85,7 +85,7 @@ public class BlockRedstoneNotGate extends Block { } } } - + @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) { if (!this.canBlockStay(world, x, y, z)) { this.dropBlockWithCause(world, EnumDropCause.WORLD, x, y, z, world.getBlockMetadata(x, y, z), null); @@ -125,11 +125,11 @@ public class BlockRedstoneNotGate extends Block { return false; } } - + @Override public boolean canProvidePower() { return false; } - + @Override public void onBlockPlaced(World world, int x, int y, int z, Side side, EntityLiving entity, double sideHeight) { int l = entity.getHorizontalPlacementDirection(side).index; world.setBlockMetadataWithNotify(x, y, z, l); @@ -138,7 +138,7 @@ public class BlockRedstoneNotGate extends Block { world.scheduleBlockUpdate(x, y, z, this.id, 1); } } - + @Override public void onBlockAdded(World world, int i, int j, int k) { world.notifyBlocksOfNeighborChange(i + 1, j, k, this.id); world.notifyBlocksOfNeighborChange(i - 1, j, k, this.id); diff --git a/src/main/java/turniplabs/simpletech/block/BlockTrappedChest.java b/src/main/java/turniplabs/simpletech/block/BlockTrappedChest.java @@ -16,7 +16,7 @@ public class BlockTrappedChest extends BlockChest { public BlockTrappedChest(String key, int id, Material material) { super(key, id, material); this.withTexCoords(9, 1, 9, 1, 11, 1, 10, 1, 10, 1, 10, 1); - this.setTickOnLoad(true); + this.setTicking(true); } @Override @@ -25,7 +25,7 @@ public class BlockTrappedChest extends BlockChest { } @Override - public boolean isOpaqueCube() { + public boolean isSolidRender() { return false; } @@ -45,12 +45,12 @@ public class BlockTrappedChest extends BlockChest { } @Override - public void onBlockRemoval(World world, int x, int y, int z) { + public void onBlockRemoved(World world, int x, int y, int z, int data) { if (SimpleTech.getRedstoneFromMetadata(world.getBlockMetadata(x, y, z), redstoneOffset) > 0) { this.notifyNeighbors(world, x, y, z); } - super.onBlockRemoval(world, x, y, z); + super.onBlockRemoved(world, x, y, z, data); } @Override diff --git a/src/main/java/turniplabs/simpletech/block/entity/TileEntityAllocator.java b/src/main/java/turniplabs/simpletech/block/entity/TileEntityAllocator.java @@ -65,12 +65,15 @@ public class TileEntityAllocator extends TileEntity implements IInventory { @Override public boolean canInteractWith(EntityPlayer entityPlayer) { - return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && - entityPlayer.distanceToSqr((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, - (double) this.zCoord + 0.5D) <= 64.0D; + return this.worldObj.getBlockTileEntity(this.x, this.y, this.z) == this && + entityPlayer.distanceToSqr((double) this.x + 0.5D, (double) this.y + 0.5D, + (double) this.z + 0.5D) <= 64.0D; } @Override + public void sortInventory() {} + + @Override public void readFromNBT(CompoundTag nbttagcompound) { super.readFromNBT(nbttagcompound); ListTag items = nbttagcompound.getList("Items"); diff --git a/src/main/java/turniplabs/simpletech/block/entity/TileEntityFan.java b/src/main/java/turniplabs/simpletech/block/entity/TileEntityFan.java @@ -22,10 +22,10 @@ public class TileEntityFan extends TileEntity { } @Override - public void updateEntity() { - if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) || - worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord + 1, zCoord)) { - this.blow(worldObj, xCoord, yCoord, zCoord); + public void tick() { + if (worldObj.isBlockIndirectlyGettingPowered(x, y, z) || + worldObj.isBlockIndirectlyGettingPowered(x, y + 1, z)) { + this.blow(worldObj, x, y, z); } } diff --git a/src/main/java/turniplabs/simpletech/block/entity/TileEntityLightSensor.java b/src/main/java/turniplabs/simpletech/block/entity/TileEntityLightSensor.java @@ -7,7 +7,7 @@ import turniplabs.simpletech.block.BlockLightSensor; public class TileEntityLightSensor extends TileEntity { @Override - public void updateEntity() { + public void tick() { // If the world object is valid... if (worldObj != null && !worldObj.isClientSide) { Block block = getBlockType(); @@ -16,22 +16,22 @@ public class TileEntityLightSensor extends TileEntity { BlockLightSensor lightSensor = ((BlockLightSensor) block); boolean isDay = worldObj.isDaytime(); boolean isPowered = SimpleTech.getRedstoneFromMetadata( - worldObj.getBlockMetadata(xCoord, yCoord, zCoord), + worldObj.getBlockMetadata(x, y, z), BlockLightSensor.redstoneOffset) > 0; - boolean isInverted = lightSensor.isInverted(worldObj, xCoord, yCoord, zCoord); + boolean isInverted = lightSensor.isInverted(worldObj, x, y, z); if (isInverted) { // Daytime mode. if (isDay && !isPowered) // Sends redstone value. - lightSensor.updateSensor(worldObj, xCoord, yCoord, zCoord, true); + lightSensor.updateSensor(worldObj, x, y, z, true); if (!isDay && isPowered) - lightSensor.updateSensor(worldObj, xCoord, yCoord, zCoord, false); + lightSensor.updateSensor(worldObj, x, y, z, false); } else { // Nighttime mode. if (isDay && isPowered) - lightSensor.updateSensor(worldObj, xCoord, yCoord, zCoord, false); + lightSensor.updateSensor(worldObj, x, y, z, false); if (!isDay && !isPowered) - lightSensor.updateSensor(worldObj, xCoord, yCoord, zCoord, true); + lightSensor.updateSensor(worldObj, x, y, z, true); } } } diff --git a/src/main/java/turniplabs/simpletech/mixin/MinecraftMixin.java b/src/main/java/turniplabs/simpletech/mixin/MinecraftMixin.java @@ -1,20 +0,0 @@ -package turniplabs.simpletech.mixin; - -import net.minecraft.client.Minecraft; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = Minecraft.class, remap = false) -final class MinecraftMixin { - @Shadow - private static Minecraft theMinecraft; - - @Inject(method = "getMinecraft(Ljava/lang/Class;)Lnet/minecraft/client/Minecraft;", at = @At("HEAD"), - require = 0, cancellable = true) - private static void removeGetterLimitation(Class<?> caller, CallbackInfoReturnable<Minecraft> cir) { - cir.setReturnValue(theMinecraft); - } -} diff --git a/src/main/java/turniplabs/simpletech/mixin/NetClientHandlerMixin.java b/src/main/java/turniplabs/simpletech/mixin/NetClientHandlerMixin.java @@ -3,6 +3,7 @@ package turniplabs.simpletech.mixin; import net.minecraft.client.Minecraft; import net.minecraft.client.net.handler.NetClientHandler; import net.minecraft.core.net.packet.Packet100OpenWindow; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -14,6 +15,7 @@ import turniplabs.simpletech.block.entity.TileEntityAllocator; @Mixin(value = NetClientHandler.class, remap = false) public class NetClientHandlerMixin { + @Final @Shadow private Minecraft mc; @Inject(method = "handleOpenWindow(Lnet/minecraft/core/net/packet/Packet100OpenWindow;)V", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/turniplabs/simpletech/mixin/RenderBlocksMixin.java b/src/main/java/turniplabs/simpletech/mixin/RenderBlocksMixin.java @@ -11,7 +11,7 @@ import turniplabs.simpletech.block.BlockFan; @Mixin(value = RenderBlocks.class, remap = false) final class RenderBlocksMixin { - @Redirect(method = "renderBlockOnInventory", at = @At(value = "INVOKE", + @Redirect(method = "renderBlockOnInventory(Lnet/minecraft/core/block/Block;IFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/block/Block;getBlockTextureFromSideAndMetadata(Lnet/minecraft/core/util/helper/Side;I)I"), require = 0) private int changeBlockInventoryRender(Block block, Side side, int meta) { diff --git a/src/main/resources/assets/simpletech/recipes/workbench.json b/src/main/resources/assets/simpletech/recipes/workbench.json @@ -0,0 +1,175 @@ +[ + { + "name": "simpletech:workbench/fan", + "type": "minecraft:crafting/shaped", + "pattern": [ + "CCC", + "CIC", + "CRC" + ], + "symbols": [ + { + "symbol": "C", + "stack": { + "key": "tile.cobble.stone", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "I", + "stack": { + "key": "item.ingot.iron", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "R", + "stack": { + "key": "item.dust.redstone", + "amount": 1, + "meta": 0 + } + } + ], + "result": { + "key": "tile.simpletech.fan.unpowered", + "amount": 1, + "meta": 0 + }, + "consumeContainers": true + }, + { + "name": "simpletech:workbench/light_sensor", + "type": "minecraft:crafting/shaped", + "pattern": [ + "G", + "Q", + "S" + ], + "symbols": [ + { + "symbol": "G", + "stack": { + "key": "tile.glass", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "Q", + "stack": { + "key": "item.quartz", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "S", + "stack": { + "key": "tile.slab.planks.oak", + "amount": 1, + "meta": 0 + } + } + ], + "result": { + "key": "tile.simpletech.lightsensor", + "amount": 1, + "meta": 0 + }, + "consumeContainers": true + }, + { + "name": "simpletech:workbench/allocator", + "type": "minecraft:crafting/shaped", + "pattern": [ + "CRC", + "CGC", + "CRC" + ], + "symbols": [ + { + "symbol": "C", + "stack": { + "key": "tile.cobble.stone", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "R", + "stack": { + "key": "item.dust.redstone", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "G", + "stack": { + "key": "item.ingot.gold", + "amount": 1, + "meta": 0 + } + } + ], + "result": { + "key": "tile.simpletech.allocator", + "amount": 1, + "meta": 0 + }, + "consumeContainers": true + }, + { + "name": "simpletech:workbench/jump_pad", + "type": "minecraft:crafting/shapeless", + "inputs": [ + { + "stack": { + "key": "item.slimeball", + "amount": 1, + "meta": 0 + } + }, + { + "stack": { + "key": "tile.slab.planks.oak", + "amount": 1, + "meta": 0 + } + } + ], + "result": { + "key": "tile.simpletech.jumppad", + "amount": 1, + "meta": 0 + } + }, + { + "name": "simpletech:workbench/trapped_chest", + "type": "minecraft:crafting/shapeless", + "inputs": [ + { + "stack": { + "key": "tile.chest.planks.oak", + "amount": 1, + "meta": 0 + } + }, + { + "stack": { + "key": "item.dust.redstone", + "amount": 1, + "meta": 0 + } + } + ], + "result": { + "key": "tile.simpletech.chest.trapped", + "amount": 1, + "meta": 0 + } + } +] +\ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json @@ -16,8 +16,11 @@ "icon": "icon.png", "environment": "*", "entrypoints": { - "main": [ + "beforeGameStart": [ "turniplabs.simpletech.SimpleTech" + ], + "recipesReady": [ + "turniplabs.simpletech.SimpleTechRecipes" ] }, "mixins": [ @@ -25,7 +28,7 @@ ], "depends": { "fabricloader": ">=0.13.3", - "halplibe": ">=2.1.6", + "halplibe": ">=2.6.0", "minecraft": ">=1.7.7.0" }, "suggests": { diff --git a/src/main/resources/simpletech.mixins.json b/src/main/resources/simpletech.mixins.json @@ -6,14 +6,13 @@ "mixins": [ "EntityItemMixin", "EntityPlayerMixin", - "EntityPlayerMPMixin", + "EntityPlayerMPMixin" + ], + "client": [ "EntityPlayerSPMixin", - "MinecraftMixin", "NetClientHandlerMixin", "RenderBlocksMixin" ], - "client": [ - ], "injectors": { "defaultRequire": 1 }