From 15680a6c0be4d35a79f192482f6a4672954d9cab Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 9 Mar 2020 01:06:34 +0100 Subject: [PATCH] Server-side and Migration crashes - Fixed crash on server start-up - Fixed internal server error when equipping a blockzapper - "Fixed" belts not behaving when migrated from 0.1 (destroying them) - Fixed Saws not having a kill message - Fixed Drill not damaging entities - Added recipe for the storage interface --- .../com/simibubi/create/ScreenResources.java | 22 ++++++++++------- .../components/actors/DrillBlock.java | 19 +++++++++++++++ .../contraptions/components/saw/SawBlock.java | 2 +- .../relays/belt/BeltTileEntity.java | 9 +++++++ .../terrainzapper/TerrainzapperItem.java | 1 + .../resources/assets/create/lang/en_us.json | 1 + .../portable_storage_interface.json | 24 +++++++++++++++++++ 7 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/data/create/recipes/crafting_shaped/contraptions/portable_storage_interface.json diff --git a/src/main/java/com/simibubi/create/ScreenResources.java b/src/main/java/com/simibubi/create/ScreenResources.java index 0d9679885..a155a69ae 100644 --- a/src/main/java/com/simibubi/create/ScreenResources.java +++ b/src/main/java/com/simibubi/create/ScreenResources.java @@ -4,6 +4,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.screen.Screen; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public enum ScreenResources { @@ -39,7 +41,7 @@ public enum ScreenResources { FILTER("filter.png", 200, 100), ATTRIBUTE_FILTER("filter.png", 0, 100, 200, 86), - + // Logistical Index INDEX_TOP("index.png", 41, 0, 174, 22), INDEX_TOP_TRIM("index.png", 41, 22, 174, 6), @@ -111,7 +113,7 @@ public enum ScreenResources { I_WHITELIST_NOT(12, 0), I_RESPECT_NBT(13, 0), I_IGNORE_NBT(14, 0), - + I_CONFIRM(0, 1), I_NONE(1, 1), I_OPEN_FOLDER(2, 1), @@ -124,7 +126,7 @@ public enum ScreenResources { I_MOVE_PLACE(9, 1), I_MOVE_PLACE_RETURNED(10, 1), I_MOVE_NEVER_PLACE(11, 1), - + I_DONT_REPLACE(0, 2), I_REPLACE_SOLID(1, 2), I_REPLACE_ANY(2, 2), @@ -142,7 +144,7 @@ public enum ScreenResources { I_TOOL_DEPLOY(0, 3), I_SKIP_TILES(2, 3), I_SKIP_MISSING(1, 3), - + I_TOOL_MOVE_XZ(0, 4), I_TOOL_MOVE_Y(1, 4), I_TOOL_ROTATE(2, 4), @@ -156,12 +158,12 @@ public enum ScreenResources { I_PATTERN_CHECKERED(1, 6), I_PATTERN_CHECKERED_INVERSED(2, 6), I_PATTERN_CHANCE_25(3, 6), - + I_PATTERN_CHANCE_50(0, 7), I_PATTERN_CHANCE_75(1, 7), I_FOLLOW_DIAGONAL(2, 7), I_FOLLOW_MATERIAL(3, 7), - + ; public static final int FONT_COLOR = 0x575F7A; @@ -169,8 +171,6 @@ public enum ScreenResources { public final ResourceLocation location; public int width, height; public int startX, startY; - static Screen renderer = new Screen(null) { - }; private ScreenResources(String location, int width, int height) { this(location, 0, 0, width, height); @@ -188,17 +188,21 @@ public enum ScreenResources { this.startY = startY; } + @OnlyIn(Dist.CLIENT) public void bind() { Minecraft.getInstance().getTextureManager().bindTexture(location); } + @OnlyIn(Dist.CLIENT) public void draw(AbstractGui screen, int x, int y) { bind(); screen.blit(x, y, startX, startY, width, height); } + @OnlyIn(Dist.CLIENT) public void draw(int x, int y) { - draw(renderer, x, y); + draw(new Screen(null) { + }, x, y); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java index 30464104a..b63e98d2e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java @@ -10,10 +10,15 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.PushReaction; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; @@ -23,6 +28,7 @@ import net.minecraft.world.World; public class DrillBlock extends DirectionalKineticBlock implements IPortableBlock, IWithTileEntity { public static MovementBehaviour MOVEMENT = new DrillMovementBehaviour(); + public static DamageSource damageSourceDrill = new DamageSource("create.drill").setDamageBypassesArmor(); public DrillBlock() { super(Properties.from(Blocks.IRON_BLOCK)); @@ -33,6 +39,19 @@ public class DrillBlock extends DirectionalKineticBlock implements IPortableBloc return true; } + @Override + public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + if (entityIn instanceof ItemEntity) + return; + if (!new AxisAlignedBB(pos).shrink(.1f).intersects(entityIn.getBoundingBox())) + return; + withTileEntityDo(worldIn, pos, te -> { + if (te.getSpeed() == 0) + return; + entityIn.attackEntityFrom(damageSourceDrill, MathHelper.clamp(Math.abs(te.getSpeed() / 32f) + 1, 0, 20)); + }); + } + @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new DrillTileEntity(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java index d7b51c012..82ed7578a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java @@ -88,7 +88,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements IWithTileEn withTileEntityDo(worldIn, pos, te -> { if (te.getSpeed() == 0) return; - entityIn.attackEntityFrom(damageSourceSaw, MathHelper.clamp(Math.abs(te.getSpeed() / 512f) + 1, 0, 20)); + entityIn.attackEntityFrom(damageSourceSaw, MathHelper.clamp(Math.abs(te.getSpeed() / 32f) + 1, 0, 20)); }); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java index feaf1845d..56575fbfa 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java @@ -65,6 +65,15 @@ public class BeltTileEntity extends KineticTileEntity { index = -1; } + @Override + public void initialize() { + super.initialize(); + // 0.1 belt + if (beltLength == 0) { + world.destroyBlock(pos, true); + } + } + @Override public void tick() { super.tick(); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItem.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItem.java index ca1c8db20..6f92d993f 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItem.java @@ -30,6 +30,7 @@ public class TerrainzapperItem extends ZapperItem implements IHaveCustomItemMode } @Override + @OnlyIn(value = Dist.CLIENT) protected void openHandgunGUI(ItemStack item, boolean b) { ScreenOpener.open(new TerrainzapperScreen(item, b)); } diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index df0d95a12..f1e69f91e 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -273,6 +273,7 @@ "death.attack.create.fan_fire": "%1$s was burned to death by hot air", "death.attack.create.fan_lava": "%1$s was burned to death by lava fan", "death.attack.create.drill": "%1$s was impaled by Mechanical Drill", + "death.attack.create.saw": "%1$s got cut in half by Mechanical Saw", "create.block.deployer.damage_source_name": "a rogue Deployer", "death.attack.create.curse_polish": "%1$s tried to polish a cursed item", "death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock", diff --git a/src/main/resources/data/create/recipes/crafting_shaped/contraptions/portable_storage_interface.json b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/portable_storage_interface.json new file mode 100644 index 000000000..4cbcbaadd --- /dev/null +++ b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/portable_storage_interface.json @@ -0,0 +1,24 @@ +{ + "type": "crafting_shaped", + "pattern": [ + "LT" + ], + "key": { + "L": { + "item": "create:andesite_casing" + }, + "T": { + "item": "create:extractor" + } + }, + "result": { + "item": "create:portable_storage_interface", + "count": 1 + }, + "conditions": [ + { + "type": "create:module", + "module": "contraptions" + } + ] +} \ No newline at end of file