From d0c32e8efb88b9864c1f5a175174e24cb469a23b Mon Sep 17 00:00:00 2001 From: KnatteAnka Date: Tue, 28 Jul 2020 12:56:07 +0200 Subject: [PATCH 1/3] Add rails and minecart to blast furnace to get iron back. (#2177) Thanks to KnatteAnka * Adding Iron from Mincart * Adding Iron from Rail --- .../iron_ingot_from_minecart.json | 23 ++++++++++++++++++ .../blast_furnace/iron_ingot_from_rail.json | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_minecart.json create mode 100644 src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_rail.json diff --git a/src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_minecart.json b/src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_minecart.json new file mode 100644 index 000000000..50aacff14 --- /dev/null +++ b/src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_minecart.json @@ -0,0 +1,23 @@ +{ + "type": "techreborn:blast_furnace", + "power": 128, + "time": 140, + "heat": 1000, + "ingredients" : [ + { + "item": "minecraft:minecart" + }, + { + "item": "minecraft:sand" + } + ], + "results" : [ + { + "item": "minecraft:iron_ingot", + "count": 5 + }, + { + "item": "techreborn:dark_ashes_dust" + } + ] +} diff --git a/src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_rail.json b/src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_rail.json new file mode 100644 index 000000000..eea8abb35 --- /dev/null +++ b/src/main/resources/data/techreborn/recipes/blast_furnace/iron_ingot_from_rail.json @@ -0,0 +1,24 @@ +{ + "type": "techreborn:blast_furnace", + "power": 128, + "time": 140, + "heat": 1000, + "ingredients" : [ + { + "item": "minecraft:rail", + "count":12 + }, + { + "item": "minecraft:sand" + } + ], + "results" : [ + { + "item": "minecraft:iron_ingot", + "count": 3 + }, + { + "item": "techreborn:dark_ashes_dust" + } + ] +} From a0644ac434ab8f86bfdc07960c5afbc0e9ec270b Mon Sep 17 00:00:00 2001 From: Deximus-Maximus Date: Tue, 28 Jul 2020 08:13:19 -0400 Subject: [PATCH 2/3] AutoSwitch support (#2175). Thanks to dexman545 --- build.gradle | 2 + .../compat/autoswitch/AutoSwitchApiImpl.java | 42 +++++++++++++++++++ src/main/resources/fabric.mod.json | 5 ++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/main/java/techreborn/compat/autoswitch/AutoSwitchApiImpl.java diff --git a/build.gradle b/build.gradle index d839014be..c41fb1157 100644 --- a/build.gradle +++ b/build.gradle @@ -93,6 +93,8 @@ dependencies { compileOnly "com.google.code.findbugs:jsr305:3.0.2" modApi 'teamreborn:energy:0.1.0' + + optionalDependency "com.github.dexman545:autoswitch-api:-SNAPSHOT" } def optionalDependency(String dep) { diff --git a/src/main/java/techreborn/compat/autoswitch/AutoSwitchApiImpl.java b/src/main/java/techreborn/compat/autoswitch/AutoSwitchApiImpl.java new file mode 100644 index 000000000..18c4c43b0 --- /dev/null +++ b/src/main/java/techreborn/compat/autoswitch/AutoSwitchApiImpl.java @@ -0,0 +1,42 @@ +package techreborn.compat.autoswitch; + +import autoswitch.api.AutoSwitchApi; +import autoswitch.api.AutoSwitchMap; +import autoswitch.api.DurabilityGetter; +import net.minecraft.item.Item; +import net.minecraft.tag.Tag; +import org.apache.commons.lang3.tuple.Pair; +import reborncore.common.util.ItemUtils; +import techreborn.items.tool.ChainsawItem; +import techreborn.items.tool.DrillItem; +import techreborn.items.tool.JackhammerItem; +import techreborn.items.tool.advanced.RockCutterItem; +import techreborn.items.tool.basic.ElectricTreetapItem; +import techreborn.items.tool.industrial.NanosaberItem; +import techreborn.items.tool.industrial.OmniToolItem; + +public class AutoSwitchApiImpl implements AutoSwitchApi { + + @Override + public void moddedTargets(AutoSwitchMap targets, AutoSwitchMap actionConfig, AutoSwitchMap usableConfig) { + + } + + @Override + public void moddedToolGroups(AutoSwitchMap, Class>> toolGroupings) { + + } + + @Override + public void customDamageSystems(AutoSwitchMap, DurabilityGetter> damageMap) { + // Multiple by 100 to get percentage out of decimal form + damageMap.put(DrillItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + damageMap.put(ChainsawItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + damageMap.put(JackhammerItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + damageMap.put(NanosaberItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + damageMap.put(OmniToolItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + damageMap.put(ElectricTreetapItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + damageMap.put(RockCutterItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack)); + + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c33222225..f7142f2e4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,7 +24,10 @@ ], "libcd": [ "techreborn.compat.libcd.LibCDPlugin" - ] + ], + "autoswitch": [ + "techreborn.compat.autoswitch.AutoSwitchApiImpl" + ] }, "depends": { "fabricloader": ">=0.6.3", From dc1e459ad62a06af37bd3eebdfa2c9d663785478 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Sun, 9 Aug 2020 21:01:07 +0300 Subject: [PATCH 3/3] Discharge cable on shock. Closes #2178 --- .../techreborn/blocks/cable/CableBlock.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/techreborn/blocks/cable/CableBlock.java b/src/main/java/techreborn/blocks/cable/CableBlock.java index c16413107..1dba38a64 100644 --- a/src/main/java/techreborn/blocks/cable/CableBlock.java +++ b/src/main/java/techreborn/blocks/cable/CableBlock.java @@ -102,9 +102,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { public BooleanProperty getProperty(Direction facing) { switch (facing) { - case EAST: - return EAST; - case WEST: + case WEST: return WEST; case NORTH: return NORTH; @@ -120,18 +118,18 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { } private BlockState makeConnections(World world, BlockPos pos) { - Boolean down = canConnectTo(world, pos.offset(Direction.DOWN, 1), Direction.UP); - Boolean up = canConnectTo(world, pos.up(), Direction.DOWN); - Boolean north = canConnectTo(world, pos.north(), Direction.SOUTH); - Boolean east = canConnectTo(world, pos.east(), Direction.WEST); - Boolean south = canConnectTo(world, pos.south(), Direction.NORTH); - Boolean west = canConnectTo(world, pos.west(), Direction.WEST); + Boolean down = canConnectTo(world, pos.down()); + Boolean up = canConnectTo(world, pos.up()); + Boolean north = canConnectTo(world, pos.north()); + Boolean east = canConnectTo(world, pos.east()); + Boolean south = canConnectTo(world, pos.south()); + Boolean west = canConnectTo(world, pos.west()); return this.getDefaultState().with(DOWN, down).with(UP, up).with(NORTH, north).with(EAST, east) .with(SOUTH, south).with(WEST, west); } - private Boolean canConnectTo(WorldAccess world, BlockPos pos, Direction facing) { + private Boolean canConnectTo(WorldAccess world, BlockPos pos) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity != null && (Energy.valid(blockEntity) || blockEntity instanceof CableBlockEntity)) { return Boolean.TRUE; @@ -152,6 +150,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { } // Block + @SuppressWarnings("deprecation") @Override public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); @@ -199,16 +198,18 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { .with(WATERLOGGED, context.getWorld().getFluidState(context.getBlockPos()).getFluid() == Fluids.WATER); } + @SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState ourState, Direction ourFacing, BlockState otherState, WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) { if (ourState.get(WATERLOGGED)) { worldIn.getFluidTickScheduler().schedule(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); } - Boolean value = canConnectTo(worldIn, otherPos, ourFacing.getOpposite()); + Boolean value = canConnectTo(worldIn, otherPos); return ourState.with(getProperty(ourFacing), value); } + @SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext shapeContext) { if (state.get(COVERED)) { @@ -217,6 +218,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { return cableShapeUtil.getShape(state); } + @SuppressWarnings("deprecation") @Override public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { super.onEntityCollision(state, worldIn, pos, entityIn); @@ -245,6 +247,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { entityIn.setOnFireFor(1); } entityIn.damage(new ElectrialShockSource(), 1F); + blockEntityCable.setEnergy(0d); } if (TechRebornConfig.uninsulatedElectrocutionSound) { worldIn.playSound(null, entityIn.getX(), entityIn.getY(), entityIn.getZ(), ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS, @@ -265,6 +268,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { return !state.get(COVERED) && Waterloggable.super.canFillWithFluid(view, pos, state, fluid); } + @SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState state) { return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);