From c96feedb9152744a34b9f54289456317ea5621d7 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Sun, 2 Aug 2020 16:56:49 +0200 Subject: [PATCH 01/14] Changed version to 1.14 --- build.gradle | 12 ++++++------ src/main/resources/META-INF/mods.toml | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 425ef7d..e0a9f3e 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.15-1.0' +version = '1.14-1.0' group = 'thetadev.constructionwand' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'constructionwand' @@ -25,7 +25,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20200514-1.15.1' + mappings channel: 'snapshot', version: '20190719-1.14.3' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -98,14 +98,14 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.15.2-31.2.31' + minecraft 'net.minecraftforge:forge:1.14.4-28.2.23' - runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-32.160") - runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0.2.4") + //runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-32.160") + //runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0.2.4") compileOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455:api") - runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455") + //runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455") // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 15fdc84..573e6d5 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[31,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[28,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # A URL to refer people to when problems occur with this mod #issueTrackerURL="https://github.com/Theta-Dev/ConstructionWand" #optional # A list of mods - how many allowed here is determined by the individual mod loader @@ -35,24 +35,24 @@ With a Construction Wand you can place multiple blocks (up to 1024) at once, ext Sneak+Right click to activate angel mode which allows you to place a block at the opposite side of the block facing you. If you concentrate enough, you can even conjure a block in mid air! -This is my first minecraft mod. May the odds be ever in your favor! +This is my first minecraft mod. May the odds be ever in your favor. ''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.examplemod]] #optional +[[dependencies.constructionwand]] #optional # the modid of the dependency modId="forge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[31,)" #mandatory + versionRange="[28,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER side="BOTH" # Here's another dependency -[[dependencies.examplemod]] +[[dependencies.constructionwand]] modId="minecraft" mandatory=true - versionRange="[1.15.2]" + versionRange="[1.14.4]" ordering="NONE" side="BOTH" From 36fa9efb32c1ecc41a8d8b017bbcdb7e7c658aad Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Sun, 2 Aug 2020 16:59:41 +0200 Subject: [PATCH 02/14] Changed version to 1.14 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e0a9f3e..94de9a9 100644 --- a/build.gradle +++ b/build.gradle @@ -103,7 +103,7 @@ dependencies { //runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-32.160") //runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0.2.4") - compileOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455:api") + compileOnly fg.deobf("vazkii.botania:Botania:r1.11-379.354:api") //runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455") From d3eaa2250585f1728062fb7d8b68a1ce83b7df48 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Sun, 2 Aug 2020 17:41:30 +0200 Subject: [PATCH 03/14] Ported to 1.14 --- build.gradle | 7 ++-- .../constructionwand/client/KeyEvents.java | 2 +- .../client/RenderBlockPreview.java | 23 +++--------- .../constructionwand/client/RenderTypes.java | 37 ------------------- .../constructionwand/items/ItemWand.java | 6 +-- 5 files changed, 13 insertions(+), 62 deletions(-) delete mode 100644 src/main/java/thetadev/constructionwand/client/RenderTypes.java diff --git a/build.gradle b/build.gradle index 94de9a9..71f9c48 100644 --- a/build.gradle +++ b/build.gradle @@ -100,12 +100,11 @@ dependencies { // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.14.4-28.2.23' - //runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-32.160") - //runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0.2.4") + runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.14.4-1.1-25.135") + runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.14.4-1.0.6.1") compileOnly fg.deobf("vazkii.botania:Botania:r1.11-379.354:api") - - //runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455") + runtimeOnly fg.deobf("vazkii.botania:Botania:r1.11-379.354") // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" diff --git a/src/main/java/thetadev/constructionwand/client/KeyEvents.java b/src/main/java/thetadev/constructionwand/client/KeyEvents.java index 21a7e03..56581f1 100644 --- a/src/main/java/thetadev/constructionwand/client/KeyEvents.java +++ b/src/main/java/thetadev/constructionwand/client/KeyEvents.java @@ -74,7 +74,7 @@ public class KeyEvents // Send undo blocks to player sneaking with wand @SubscribeEvent public void sneak(InputUpdateEvent e) { - if(e.getMovementInput().sneaking) { + if(e.getMovementInput().sneak) { PlayerEntity player = e.getPlayer(); if(WandUtil.holdingWand(player) == null) return; diff --git a/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java b/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java index a399141..d82320c 100644 --- a/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java +++ b/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java @@ -1,8 +1,5 @@ package thetadev.constructionwand.client; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -11,11 +8,9 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; -import net.minecraftforge.client.event.DrawHighlightEvent; +import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import thetadev.constructionwand.ConstructionWand; import thetadev.constructionwand.basics.WandUtil; -import thetadev.constructionwand.job.ConstructionJob; import thetadev.constructionwand.job.WandJob; import java.util.LinkedList; @@ -26,7 +21,7 @@ public class RenderBlockPreview public LinkedList undoBlocks; @SubscribeEvent - public void renderAdditionalBlockBounds(DrawHighlightEvent event) + public void renderAdditionalBlockBounds(DrawBlockHighlightEvent event) { if(event.getTarget().getType() != RayTraceResult.Type.BLOCK) return; @@ -53,22 +48,16 @@ public class RenderBlockPreview if(blocks == null || blocks.isEmpty()) return; - MatrixStack ms = event.getMatrix(); - IRenderTypeBuffer buffer = event.getBuffers(); - ms.push(); - for(BlockPos block : blocks) { double partialTicks = event.getPartialTicks(); - double d0 = player.lastTickPosX + (player.getPosX() - player.lastTickPosX) * partialTicks; - double d1 = player.lastTickPosY + player.getEyeHeight() + (player.getPosY() - player.lastTickPosY) * partialTicks; - double d2 = player.lastTickPosZ + (player.getPosZ() - player.lastTickPosZ) * partialTicks; + double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; + double d1 = player.lastTickPosY + player.getEyeHeight() + (player.posY - player.lastTickPosY) * partialTicks; + double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; AxisAlignedBB aabb = new AxisAlignedBB(block).offset(-d0, -d1, -d2); - IVertexBuilder lineBuilder = buffer.getBuffer(RenderTypes.TRANSLUCENT_LINES); - WorldRenderer.drawBoundingBox(ms, lineBuilder, aabb, colorR, colorG, colorB, 0.4F); + WorldRenderer.drawSelectionBoundingBox(aabb, colorR, colorG, colorB, 0.4F); } - ms.pop(); event.setCanceled(true); } diff --git a/src/main/java/thetadev/constructionwand/client/RenderTypes.java b/src/main/java/thetadev/constructionwand/client/RenderTypes.java deleted file mode 100644 index c3759b7..0000000 --- a/src/main/java/thetadev/constructionwand/client/RenderTypes.java +++ /dev/null @@ -1,37 +0,0 @@ -package thetadev.constructionwand.client; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.renderer.RenderState; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import org.lwjgl.opengl.GL11; -import thetadev.constructionwand.ConstructionWand; - -import java.util.OptionalDouble; - -public class RenderTypes -{ - public static final RenderType TRANSLUCENT_LINES; - - protected static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = new RenderState.TransparencyState("translucent_transparency", () -> { - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - }, RenderSystem::disableBlend); - protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState(GL11.GL_ALWAYS); - - static { - RenderType.State translucentNoDepthState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY) - .line(new RenderState.LineState(OptionalDouble.of(2))) - .texture(new RenderState.TextureState()) - .depthTest(DEPTH_ALWAYS) - .build(false); - - TRANSLUCENT_LINES = RenderType.makeType( - ConstructionWand.MODID+":translucent_lines", - DefaultVertexFormats.POSITION_COLOR, - GL11.GL_LINES, - 256, - translucentNoDepthState - ); - } -} diff --git a/src/main/java/thetadev/constructionwand/items/ItemWand.java b/src/main/java/thetadev/constructionwand/items/ItemWand.java index 2277de7..a2e4e59 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWand.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWand.java @@ -73,7 +73,7 @@ public abstract class ItemWand extends Item public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(world.isRemote) return ActionResult.resultFail(stack); + if(world.isRemote) return new ActionResult<>(ActionResultType.FAIL, stack); if(player.isSneaking()) { // SHIFT + Right click: Change wand mode @@ -86,13 +86,13 @@ public abstract class ItemWand extends Item optionMessage(player, opt); player.inventory.markDirty(); - return ActionResult.resultSuccess(stack); + return new ActionResult<>(ActionResultType.SUCCESS, stack); } else { // Right click: Place angel block //ConstructionWand.LOGGER.debug("Place angel block"); WandJob job = new AngelJob(player, world, stack); - return job.doIt() ? ActionResult.resultSuccess(stack) : ActionResult.resultFail(stack); + return new ActionResult<>(job.doIt() ? ActionResultType.SUCCESS : ActionResultType.FAIL, stack); } } From 493861f8c9c9a357dbb41abe336bd2851489c9da Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Sun, 2 Aug 2020 18:09:42 +0200 Subject: [PATCH 04/14] Improved Preview Renderer --- .../client/RenderBlockPreview.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java b/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java index d82320c..4fcf146 100644 --- a/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java +++ b/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java @@ -1,6 +1,9 @@ package thetadev.constructionwand.client; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -56,9 +59,40 @@ public class RenderBlockPreview double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; AxisAlignedBB aabb = new AxisAlignedBB(block).offset(-d0, -d1, -d2); - WorldRenderer.drawSelectionBoundingBox(aabb, colorR, colorG, colorB, 0.4F); + //WorldRenderer.drawSelectionBoundingBox(aabb, colorR, colorG, colorB, 0.4F); + drawBoundingBox(aabb, colorR, colorG, colorB, 0.4F); } event.setCanceled(true); } + + private static void drawBoundingBox(AxisAlignedBB box, float red, float green, float blue, float alpha) { + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder buffer = tessellator.getBuffer(); + buffer.begin(3, DefaultVertexFormats.POSITION_COLOR); + + //Base + buffer.pos(box.minX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.maxX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.maxX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.minX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.minX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex(); + //Side1 + buffer.pos(box.minX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.minX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.minX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex(); + //Side2 + buffer.pos(box.minX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.maxX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.maxX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex(); + //Side3 + buffer.pos(box.maxX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.maxX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.maxX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex(); + //Side4 + buffer.pos(box.maxX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex(); + buffer.pos(box.minX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex(); + + tessellator.draw(); + } } From dfbdb10a800183ba329a7fc686ed348d9deeb992 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Mon, 3 Aug 2020 00:57:48 +0200 Subject: [PATCH 05/14] Fixed key events --- .../constructionwand/client/KeyEvents.java | 22 ++++++++++--------- .../assets/constructionwand/lang/de_de.json | 1 + .../assets/constructionwand/lang/en_us.json | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/thetadev/constructionwand/client/KeyEvents.java b/src/main/java/thetadev/constructionwand/client/KeyEvents.java index f999acd..48bc90c 100644 --- a/src/main/java/thetadev/constructionwand/client/KeyEvents.java +++ b/src/main/java/thetadev/constructionwand/client/KeyEvents.java @@ -27,9 +27,11 @@ public class KeyEvents private final String langPrefix = ConstructionWand.MODID + ".key."; private final String langCategory = langPrefix + "category"; - public final KeyBinding[] keys = { - new KeyBinding(langPrefix+"direction", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_N, 0), langCategory), - new KeyBinding(langPrefix+"fluid", KeyConflictContext.IN_GAME, KeyModifier.SHIFT, InputMappings.getInputByCode(GLFW.GLFW_KEY_N, 0), langCategory) + public final KeyBinding WAND_KEY = new KeyBinding(langPrefix+"wand", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_N, 0), langCategory); + + public static final KeyModifier[] keyModifiers = { + KeyModifier.NONE, + KeyModifier.SHIFT }; public static final IEnumOption[] keyOptions = { @@ -38,17 +40,17 @@ public class KeyEvents }; public KeyEvents() { - for(KeyBinding key : keys) ClientRegistry.registerKeyBinding(key); + ClientRegistry.registerKeyBinding(WAND_KEY); } @SubscribeEvent public void KeyEvent(InputEvent.KeyInputEvent e) { - boolean sendPacket = false; - - for(int i=0; i Date: Mon, 3 Aug 2020 19:06:24 +0200 Subject: [PATCH 06/14] tiny fix --- .../thetadev/constructionwand/client/RenderBlockPreview.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java b/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java index d0132ce..ff96fe8 100644 --- a/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java +++ b/src/main/java/thetadev/constructionwand/client/RenderBlockPreview.java @@ -1,8 +1,8 @@ package thetadev.constructionwand.client; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -24,7 +24,7 @@ public class RenderBlockPreview public LinkedList undoBlocks; @SubscribeEvent - public void renderBlockHighlight(DrawHighlightEvent event) + public void renderBlockHighlight(DrawBlockHighlightEvent event) { if(event.getTarget().getType() != RayTraceResult.Type.BLOCK) return; From 2df50e381d3f986853b9f6a2a9e580daeae46bd5 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Mon, 3 Aug 2020 19:30:55 +0200 Subject: [PATCH 07/14] Fixed tooltip not showing angel mode --- src/main/java/thetadev/constructionwand/items/ItemWand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/thetadev/constructionwand/items/ItemWand.java b/src/main/java/thetadev/constructionwand/items/ItemWand.java index 1b72703..ec188a2 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWand.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWand.java @@ -136,7 +136,7 @@ public abstract class ItemWand extends Item IEnumOption opt = WandOptions.options[0]; lines.add(new TranslationTextComponent(langTooltip + "blocks", wand.maxBlocks).applyTextStyle(TextFormatting.GRAY)); lines.add(new TranslationTextComponent(langPrefix+opt.getOptionKey()).applyTextStyle(TextFormatting.AQUA) - .appendSibling(new TranslationTextComponent(langPrefix+opt.getTranslationKey()).applyTextStyle(TextFormatting.WHITE))); + .appendSibling(new TranslationTextComponent(langPrefix+options.getOption(opt).getTranslationKey()).applyTextStyle(TextFormatting.WHITE))); lines.add(new TranslationTextComponent(langTooltip + "shift").applyTextStyle(TextFormatting.AQUA)); } } From e3d6f161a220a5938c9f4fedc664c71e6a9936c4 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Mon, 3 Aug 2020 19:52:53 +0200 Subject: [PATCH 08/14] more tiny fixes --- src/main/java/thetadev/constructionwand/items/ItemWand.java | 2 +- src/main/java/thetadev/constructionwand/job/AngelJob.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/thetadev/constructionwand/items/ItemWand.java b/src/main/java/thetadev/constructionwand/items/ItemWand.java index ec188a2..e13f2fd 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWand.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWand.java @@ -54,7 +54,7 @@ public abstract class ItemWand extends Item Hand hand = context.getHand(); World world = context.getWorld(); - if(world.isRemote) return ActionResultType.FAIL; + if(world.isRemote || player == null) return ActionResultType.FAIL; ItemStack stack = player.getHeldItem(hand); diff --git a/src/main/java/thetadev/constructionwand/job/AngelJob.java b/src/main/java/thetadev/constructionwand/job/AngelJob.java index 4e93be1..1c0b499 100644 --- a/src/main/java/thetadev/constructionwand/job/AngelJob.java +++ b/src/main/java/thetadev/constructionwand/job/AngelJob.java @@ -22,7 +22,7 @@ public class AngelJob extends WandJob @Override protected void getBlockPositionList() { - if(options.getOption(EnumMode.DEFAULT) != EnumMode.ANGEL) return; + if(options.getOption(EnumMode.DEFAULT) != EnumMode.ANGEL || wandItem.angelDistance == 0) return; if(!player.isCreative() && !ConfigHandler.ANGEL_FALLING.get() && player.fallDistance > 10) return; From 89fbd5313b4d3a31fc7e6fcbc8db9432010f1c24 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Mon, 3 Aug 2020 21:56:39 +0200 Subject: [PATCH 09/14] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a03775b..3338dd8 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Every wand has two additional options that can be changed using keys. (Standard: ![](https://raw.githubusercontent.com/Theta-Dev/ConstructionWand/1.15/images/placedir.png) -**Fluid lock:** Enables/disables the replacement of fluid blocks (both source + flowing). +**Replacement:** Enables/disables the replacement of replaceable blocks (snow, tallgrass and fluids). ## Additional features - If you have shulker boxes in your inventory filled with blocks, the wand can pull them out and place them @@ -48,4 +48,4 @@ Every wand has two additional options that can be changed using keys. (Standard: - Look at your statisics to see how many blocks you have placed using your wand -- **1.16 only:** The Infinity Wand won't burn in lava just like netherite gear. \ No newline at end of file +- **1.16 only:** The Infinity Wand won't burn in lava just like netherite gear. From e3918bc9bb47e594714b19a0af4a1cc19ed00295 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sat, 15 Aug 2020 21:10:51 +0200 Subject: [PATCH 10/14] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3338dd8..c50c77f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ There are four wand tiers: Stone, Iron, Diamond and Infinity. **Angel mode:** Places a block on the opposite side of the block (or row of blocks) you are facing. Maximum distance depends on wand tier. Right click empty space to place a block in midair (similar to angel blocks, hence the name). To do that, you'll need to have the block you want to place in your offhand. You can't place a block in midair if you've fallen more than 10 blocks deep (no easy rescue tool from falling into the void). ## Options +**Direction lock:** To change the direction lock, hold down SHIFT and scroll. With active direction lock the wand will only place blocks in one row or column (choose between North/South, East/West on a horizontal plane and Horizontal, Vertical on a vertical plane). If the direction lock is switched off, the wand will extend the entire face of the building it's pointed at. This option has no effect in Angel mode. + Every wand has two additional options that can be changed using keys. (Standard: N / SHIFT+N) **Placement direction:** If set to "player" the wand places blocks in the same direction as if they were placed by yourself. Target mode places the blocks in the same direction as their supporting block. See the picture below: From 1186043bf3e3aa504ecb1d0f0ee7e981a6263e17 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Wed, 26 Aug 2020 17:18:54 +0200 Subject: [PATCH 11/14] placement dir improvements --- .../java/thetadev/constructionwand/job/WandJob.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/thetadev/constructionwand/job/WandJob.java b/src/main/java/thetadev/constructionwand/job/WandJob.java index eb24b95..14eb98a 100644 --- a/src/main/java/thetadev/constructionwand/job/WandJob.java +++ b/src/main/java/thetadev/constructionwand/job/WandJob.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.state.Property; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.state.properties.SlabType; import net.minecraft.stats.Stats; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; @@ -197,7 +198,7 @@ public abstract class WandJob if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) return false; // No entities in area? - AxisAlignedBB blockBB = new AxisAlignedBB(pos); + AxisAlignedBB blockBB = blockState.getCollisionShape(world, pos).getBoundingBox().offset(pos); return world.getEntitiesWithinAABB(LivingEntity.class, blockBB, EntityPredicates.NOT_SPECTATING).isEmpty(); } @@ -215,7 +216,7 @@ public abstract class WandJob BlockState supportingBlock = placeSnapshot.supportingBlock; - if(targetDirection && placeBlock.getBlock() == supportingBlock.getBlock()) { + if(targetDirection) { // Block properties to be copied (alignment/rotation properties) for(Property property : new Property[] { BlockStateProperties.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP, @@ -225,6 +226,12 @@ public abstract class WandJob placeBlock = placeBlock.with(property, supportingBlock.get(property)); } } + + // Dont dupe double slabs + if(supportingBlock.hasProperty(BlockStateProperties.SLAB_TYPE)) { + SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE); + if(slabType != SlabType.DOUBLE) placeBlock = placeBlock.with(BlockStateProperties.SLAB_TYPE, slabType); + } } // Place the block From 64f947e53573b6d47c19175ce532a80dac1cfc4c Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Wed, 26 Aug 2020 17:24:31 +0200 Subject: [PATCH 12/14] Revert "Merge branch '1.16' into 1.15" This reverts commit cd99733803cb2443665d119338d9ba27775dc845, reversing changes made to fa1587f2697952414425df511eac1fad1e6e14e1. --- build.gradle | 26 +++++++++---- .../recipes/tools/stone_wand.json | 2 +- .../constructionwand/recipes/stone_wand.json | 2 +- .../constructionwand/ConstructionWand.java | 2 - .../constructionwand/basics/WandUtil.java | 26 +++++++------ .../constructionwand/client/KeyEvents.java | 2 +- .../constructionwand/client/RenderTypes.java | 2 +- .../thetadev/constructionwand/data/Inp.java | 6 +-- .../data/RecipeGenerator.java | 3 +- .../constructionwand/items/ItemWand.java | 22 ++++++----- .../constructionwand/items/ItemWandBasic.java | 2 - .../items/ItemWandInfinity.java | 4 +- .../constructionwand/items/ModItems.java | 12 ------ .../constructionwand/job/AngelJob.java | 12 +++--- .../job/WandItemUseContext.java | 11 +++--- .../constructionwand/job/WandJob.java | 39 +++++++------------ src/main/resources/META-INF/mods.toml | 17 ++++---- 17 files changed, 87 insertions(+), 103 deletions(-) diff --git a/build.gradle b/build.gradle index 3758453..b67dbcb 100644 --- a/build.gradle +++ b/build.gradle @@ -13,15 +13,25 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.16-1.2' +version = '1.15-1.2' group = 'thetadev.constructionwand' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'constructionwand' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. minecraft { - mappings channel: 'snapshot', version: '20200723-1.16.1' + // The mappings can be changed at any time, and must be in the following format. + // snapshot_YYYYMMDD Snapshot are built nightly. + // stable_# Stables are built at the discretion of the MCP team. + // Use non-default mappings at your own risk. they may not always work. + // Simply re-run your setup task after changing the mappings to update your workspace. + mappings channel: 'snapshot', version: '20200514-1.15.1' + // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. + + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + // Default run configurations. + // These can be tweaked, removed, or duplicated as needed. runs { client { workingDirectory project.file("run/client").canonicalPath @@ -92,12 +102,14 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.16.1-32.0.108' - //runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16-39") - //runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.16.1-3.0") + minecraft 'net.minecraftforge:forge:1.15.2-31.2.31' - compileOnly fg.deobf("vazkii.botania:Botania:1.16-398:api") - //runtimeOnly fg.deobf("vazkii.botania:Botania:1.16-398") + runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-32.160") + runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0.2.4") + + compileOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455:api") + + runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455") } jar { diff --git a/src/generated/resources/data/constructionwand/advancements/recipes/tools/stone_wand.json b/src/generated/resources/data/constructionwand/advancements/recipes/tools/stone_wand.json index c31aa4d..5b07428 100644 --- a/src/generated/resources/data/constructionwand/advancements/recipes/tools/stone_wand.json +++ b/src/generated/resources/data/constructionwand/advancements/recipes/tools/stone_wand.json @@ -11,7 +11,7 @@ "conditions": { "items": [ { - "tag": "minecraft:stone_tool_materials" + "tag": "forge:cobblestone" } ] } diff --git a/src/generated/resources/data/constructionwand/recipes/stone_wand.json b/src/generated/resources/data/constructionwand/recipes/stone_wand.json index b4448d5..114881e 100644 --- a/src/generated/resources/data/constructionwand/recipes/stone_wand.json +++ b/src/generated/resources/data/constructionwand/recipes/stone_wand.json @@ -7,7 +7,7 @@ ], "key": { "X": { - "tag": "minecraft:stone_tool_materials" + "tag": "forge:cobblestone" }, "#": { "tag": "forge:rods/wooden" diff --git a/src/main/java/thetadev/constructionwand/ConstructionWand.java b/src/main/java/thetadev/constructionwand/ConstructionWand.java index c9275c2..370ebcf 100644 --- a/src/main/java/thetadev/constructionwand/ConstructionWand.java +++ b/src/main/java/thetadev/constructionwand/ConstructionWand.java @@ -18,7 +18,6 @@ import thetadev.constructionwand.client.KeyEvents; import thetadev.constructionwand.client.RenderBlockPreview; import thetadev.constructionwand.containers.ContainerManager; import thetadev.constructionwand.containers.ContainerRegistrar; -import thetadev.constructionwand.items.ModItems; import thetadev.constructionwand.job.JobHistory; import thetadev.constructionwand.network.PacketQueryUndo; import thetadev.constructionwand.network.PacketUndoBlocks; @@ -76,6 +75,5 @@ public class ConstructionWand renderBlockPreview = new RenderBlockPreview(); MinecraftForge.EVENT_BUS.register(renderBlockPreview); MinecraftForge.EVENT_BUS.register(new KeyEvents()); - ModItems.registerModelProperties(); } } diff --git a/src/main/java/thetadev/constructionwand/basics/WandUtil.java b/src/main/java/thetadev/constructionwand/basics/WandUtil.java index 29a2f57..e902b52 100644 --- a/src/main/java/thetadev/constructionwand/basics/WandUtil.java +++ b/src/main/java/thetadev/constructionwand/basics/WandUtil.java @@ -4,10 +4,20 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.tags.ItemTags; import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import thetadev.constructionwand.basics.options.EnumMode; +import thetadev.constructionwand.basics.options.IEnumOption; +import thetadev.constructionwand.basics.options.WandOptions; import thetadev.constructionwand.items.ItemWand; +import thetadev.constructionwand.job.ConstructionJob; +import thetadev.constructionwand.job.TransductionJob; +import thetadev.constructionwand.job.WandJob; public class WandUtil { @@ -30,15 +40,7 @@ public class WandUtil return null; } - public static BlockPos playerPos(PlayerEntity player) { - return new BlockPos(player.getPositionVec()); - } - - public static Vector3d entityPositionVec(Entity entity) { - return new Vector3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight()/2, entity.getPosZ()); - } - - public static Vector3d blockPosVec(BlockPos pos) { - return new Vector3d(pos.getX(), pos.getY(), pos.getZ()); + public static Vec3d entityPositionVec(Entity entity) { + return new Vec3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight()/2, entity.getPosZ()); } } diff --git a/src/main/java/thetadev/constructionwand/client/KeyEvents.java b/src/main/java/thetadev/constructionwand/client/KeyEvents.java index b8754fa..5dd7fdb 100644 --- a/src/main/java/thetadev/constructionwand/client/KeyEvents.java +++ b/src/main/java/thetadev/constructionwand/client/KeyEvents.java @@ -58,7 +58,7 @@ public class KeyEvents ConstructionWand.instance.HANDLER.sendToServer(packet); } } - + boolean ctrlState = Screen.hasControlDown(); if(ctrlPressed != ctrlState) { ctrlPressed = ctrlState; diff --git a/src/main/java/thetadev/constructionwand/client/RenderTypes.java b/src/main/java/thetadev/constructionwand/client/RenderTypes.java index 9f665c5..c3759b7 100644 --- a/src/main/java/thetadev/constructionwand/client/RenderTypes.java +++ b/src/main/java/thetadev/constructionwand/client/RenderTypes.java @@ -17,7 +17,7 @@ public class RenderTypes RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); }, RenderSystem::disableBlend); - protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState("always", GL11.GL_ALWAYS); + protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState(GL11.GL_ALWAYS); static { RenderType.State translucentNoDepthState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY) diff --git a/src/main/java/thetadev/constructionwand/data/Inp.java b/src/main/java/thetadev/constructionwand/data/Inp.java index 07e62c0..4b52641 100644 --- a/src/main/java/thetadev/constructionwand/data/Inp.java +++ b/src/main/java/thetadev/constructionwand/data/Inp.java @@ -3,7 +3,7 @@ package thetadev.constructionwand.data; import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.item.Item; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.tags.ITag; +import net.minecraft.tags.Tag; import net.minecraft.util.IItemProvider; public class Inp @@ -21,7 +21,7 @@ public class Inp public static Inp fromItem(IItemProvider in) { return new Inp(in.asItem().getRegistryName().getPath(), Ingredient.fromItems(in), ItemPredicate.Builder.create().item(in).build()); } - public static Inp fromTag(ITag.INamedTag in) { - return new Inp(in.getName().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build()); + public static Inp fromTag(Tag in) { + return new Inp(in.getId().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build()); } } \ No newline at end of file diff --git a/src/main/java/thetadev/constructionwand/data/RecipeGenerator.java b/src/main/java/thetadev/constructionwand/data/RecipeGenerator.java index 36430c8..900d683 100644 --- a/src/main/java/thetadev/constructionwand/data/RecipeGenerator.java +++ b/src/main/java/thetadev/constructionwand/data/RecipeGenerator.java @@ -4,7 +4,6 @@ import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.RecipeProvider; import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.tags.ItemTags; import net.minecraft.util.IItemProvider; import net.minecraftforge.common.Tags; import thetadev.constructionwand.ConstructionWand; @@ -20,7 +19,7 @@ public class RecipeGenerator extends RecipeProvider @Override protected void registerRecipes(Consumer consumer) { - wandRecipe(consumer, ModItems.WAND_STONE, Inp.fromTag(ItemTags.field_232909_aa_)); //stone_tool_materials + wandRecipe(consumer, ModItems.WAND_STONE, Inp.fromTag(Tags.Items.COBBLESTONE)); wandRecipe(consumer, ModItems.WAND_IRON, Inp.fromTag(Tags.Items.INGOTS_IRON)); wandRecipe(consumer, ModItems.WAND_DIAMOND, Inp.fromTag(Tags.Items.GEMS_DIAMOND)); wandRecipe(consumer, ModItems.WAND_INFINITY, Inp.fromTag(Tags.Items.NETHER_STARS)); diff --git a/src/main/java/thetadev/constructionwand/items/ItemWand.java b/src/main/java/thetadev/constructionwand/items/ItemWand.java index e0c86db..da72444 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWand.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWand.java @@ -43,6 +43,8 @@ public abstract class ItemWand extends Item super(properties.group(ItemGroup.TOOLS)); this.maxBlocks = maxBlocks; this.angelDistance = angelDistance; + addPropertyOverride(new ResourceLocation(ConstructionWand.MODID, "wand_mode"), + (stack, worldIn, entityIn) -> getWandMode(stack)); } @Override @@ -125,17 +127,17 @@ public abstract class ItemWand extends Item if(Screen.hasShiftDown()) { for(int i=1; i event) { @@ -40,13 +37,4 @@ public class ModItems entry.setRegistryName(registryName); return entry; } - - public static void registerModelProperties() { - for(Item item : WANDS) { - ItemModelsProperties.func_239418_a_( - item, new ResourceLocation(ConstructionWand.MODID, "wand_mode"), - (stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 : ItemWand.getWandMode(stack) - ); - } - } } diff --git a/src/main/java/thetadev/constructionwand/job/AngelJob.java b/src/main/java/thetadev/constructionwand/job/AngelJob.java index 98f0e31..87b3db1 100644 --- a/src/main/java/thetadev/constructionwand/job/AngelJob.java +++ b/src/main/java/thetadev/constructionwand/job/AngelJob.java @@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import thetadev.constructionwand.basics.ConfigHandler; import thetadev.constructionwand.basics.WandUtil; @@ -14,10 +14,10 @@ import thetadev.constructionwand.basics.options.EnumMode; public class AngelJob extends WandJob { public AngelJob(PlayerEntity player, World world, ItemStack wand) { - super(player, world, new BlockRayTraceResult(player.getLookVec(), fromVector(player.getLookVec()), WandUtil.playerPos(player), false), wand); + super(player, world, new BlockRayTraceResult(player.getLookVec(), fromVector(player.getLookVec()), player.getPosition(), false), wand); } - private static Direction fromVector(Vector3d vector) { + private static Direction fromVector(Vec3d vector) { return Direction.getFacingFromVector(vector.x, vector.y, vector.z); } @@ -27,9 +27,9 @@ public class AngelJob extends WandJob if(!player.isCreative() && !ConfigHandler.ANGEL_FALLING.get() && player.fallDistance > 10) return; - Vector3d playerVec = WandUtil.entityPositionVec(player); - Vector3d lookVec = player.getLookVec().mul(2, 2, 2); - Vector3d placeVec = playerVec.add(lookVec); + Vec3d playerVec = WandUtil.entityPositionVec(player); + Vec3d lookVec = player.getLookVec().mul(2, 2, 2); + Vec3d placeVec = playerVec.add(lookVec); BlockPos currentPos = new BlockPos(placeVec); diff --git a/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java b/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java index 6daa96b..55167e9 100644 --- a/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java +++ b/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java @@ -1,11 +1,13 @@ package thetadev.constructionwand.job; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; import thetadev.constructionwand.basics.WandUtil; public class WandItemUseContext extends BlockItemUseContext @@ -14,10 +16,9 @@ public class WandItemUseContext extends BlockItemUseContext super(job.world, job.player, Hand.MAIN_HAND, new ItemStack(job.placeItem), new BlockRayTraceResult(getBlockHitVec(job, pos), job.rayTraceResult.getFace(), pos, false)); } - private static Vector3d getBlockHitVec(WandJob job, BlockPos pos) { - Vector3d hitVec = job.rayTraceResult.getHitVec(); // Absolute coords of hit target - - Vector3d blockDelta = WandUtil.blockPosVec(job.rayTraceResult.getPos()).subtract(WandUtil.blockPosVec(pos)); // Vector between start and current block + private static Vec3d getBlockHitVec(WandJob job, BlockPos pos) { + Vec3d hitVec = job.rayTraceResult.getHitVec(); // Absolute coords of hit target + Vec3d blockDelta = new Vec3d(job.rayTraceResult.getPos()).subtract(new Vec3d(pos)); // Vector between start and current block return blockDelta.add(hitVec); // Absolute coords of current block hit target } diff --git a/src/main/java/thetadev/constructionwand/job/WandJob.java b/src/main/java/thetadev/constructionwand/job/WandJob.java index 14eb98a..5a1df28 100644 --- a/src/main/java/thetadev/constructionwand/job/WandJob.java +++ b/src/main/java/thetadev/constructionwand/job/WandJob.java @@ -4,9 +4,8 @@ import net.minecraft.block.*; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; -import net.minecraft.state.Property; +import net.minecraft.state.IProperty; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.SlabType; import net.minecraft.stats.Stats; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; @@ -198,7 +197,7 @@ public abstract class WandJob if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) return false; // No entities in area? - AxisAlignedBB blockBB = blockState.getCollisionShape(world, pos).getBoundingBox().offset(pos); + AxisAlignedBB blockBB = new AxisAlignedBB(pos); return world.getEntitiesWithinAABB(LivingEntity.class, blockBB, EntityPredicates.NOT_SPECTATING).isEmpty(); } @@ -216,41 +215,29 @@ public abstract class WandJob BlockState supportingBlock = placeSnapshot.supportingBlock; - if(targetDirection) { + if(targetDirection && placeBlock.getBlock() == supportingBlock.getBlock()) { // Block properties to be copied (alignment/rotation properties) - for(Property property : new Property[] { + for(IProperty property : new IProperty[] { BlockStateProperties.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP, BlockStateProperties.ROTATION_0_15, BlockStateProperties.AXIS, BlockStateProperties.HALF, BlockStateProperties.STAIRS_SHAPE}) { - if(supportingBlock.hasProperty(property)) { + if(supportingBlock.has(property)) { placeBlock = placeBlock.with(property, supportingBlock.get(property)); } } - - // Dont dupe double slabs - if(supportingBlock.hasProperty(BlockStateProperties.SLAB_TYPE)) { - SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE); - if(slabType != SlabType.DOUBLE) placeBlock = placeBlock.with(BlockStateProperties.SLAB_TYPE, slabType); - } } + // Abort if placeEvent is canceled + BlockSnapshot snapshot = new BlockSnapshot(world, blockPos, placeBlock); + BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, placeBlock, player); + MinecraftForge.EVENT_BUS.post(placeEvent); + if(placeEvent.isCanceled()) return false; // Place the block if(!world.setBlockState(blockPos, placeBlock)) { ConstructionWand.LOGGER.info("Block could not be placed"); return false; } - - // Remove block if placeEvent is canceled - BlockSnapshot snapshot = BlockSnapshot.create(world, blockPos); - BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, placeBlock, player); - MinecraftForge.EVENT_BUS.post(placeEvent); - if(placeEvent.isCanceled()) { - world.removeBlock(blockPos, false); - return false; - } - - // Update neighbor block states - world.notifyNeighborsOfStateChange(blockPos, placeBlock.getBlock()); + world.notifyNeighbors(blockPos, placeBlock.getBlock()); // Update stats player.addStat(Stats.ITEM_USED.get(placeItem)); @@ -284,7 +271,7 @@ public abstract class WandJob // Play place sound if(!placeSnapshots.isEmpty()) { SoundType sound = placeSnapshots.getFirst().block.getSoundType(); - world.playSound(null, WandUtil.playerPos(player), sound.getPlaceSound(), SoundCategory.BLOCKS, sound.volume, sound.pitch); + world.playSound(null, player.getPosition(), sound.getPlaceSound(), SoundCategory.BLOCKS, sound.volume, sound.pitch); } // Add to job history for undo @@ -320,7 +307,7 @@ public abstract class WandJob // Play teleport sound SoundEvent sound = SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT; - world.playSound(null, WandUtil.playerPos(player), sound, SoundCategory.PLAYERS, 1.0F, 1.0F); + world.playSound(null, player.getPosition(), sound, SoundCategory.PLAYERS, 1.0F, 1.0F); return true; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 5782400..ad5e5e4 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,13 +1,12 @@ modLoader="javafml" -loaderVersion="[32,)" -license="MIT License" +loaderVersion="[31,)" [[mods]] modId="constructionwand" version="${file.jarVersion}" displayName="Construction Wand" -displayURL="https://github.com/Theta-Dev/ConstructionWand" #optional -logoFile="logo.png" #optional -authors="ThetaDev" #optional +displayURL="https://github.com/Theta-Dev/ConstructionWand" +logoFile="logo.png" +authors="ThetaDev" description=''' Construction Wands make building easier! @@ -18,14 +17,14 @@ If you concentrate enough, you can even conjure a block in mid air! This is my first minecraft mod. May the odds be ever in your favor. ''' [[dependencies.constructionwand]] - modId="forge" - mandatory=true - versionRange="[32,)" + modId="forge" #mandatory + mandatory=true #mandatory + versionRange="[31,)" #mandatory ordering="NONE" side="BOTH" [[dependencies.constructionwand]] modId="minecraft" mandatory=true - versionRange="[1.16.1]" + versionRange="[1.15.2]" ordering="NONE" side="BOTH" From 4876683b07bf48149b6a3a24c863d49a58e52dab Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Wed, 26 Aug 2020 17:39:21 +0200 Subject: [PATCH 13/14] placement dir improvements --- src/main/java/thetadev/constructionwand/job/WandJob.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/thetadev/constructionwand/job/WandJob.java b/src/main/java/thetadev/constructionwand/job/WandJob.java index 5a1df28..debb1e5 100644 --- a/src/main/java/thetadev/constructionwand/job/WandJob.java +++ b/src/main/java/thetadev/constructionwand/job/WandJob.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.state.IProperty; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.state.properties.SlabType; import net.minecraft.stats.Stats; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; @@ -197,7 +198,7 @@ public abstract class WandJob if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) return false; // No entities in area? - AxisAlignedBB blockBB = new AxisAlignedBB(pos); + AxisAlignedBB blockBB = blockState.getCollisionShape(world, pos).getBoundingBox().offset(pos); return world.getEntitiesWithinAABB(LivingEntity.class, blockBB, EntityPredicates.NOT_SPECTATING).isEmpty(); } @@ -225,6 +226,12 @@ public abstract class WandJob placeBlock = placeBlock.with(property, supportingBlock.get(property)); } } + + // Dont dupe double slabs + if(supportingBlock.has(BlockStateProperties.SLAB_TYPE)) { + SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE); + if(slabType != SlabType.DOUBLE) placeBlock = placeBlock.with(BlockStateProperties.SLAB_TYPE, slabType); + } } // Abort if placeEvent is canceled BlockSnapshot snapshot = new BlockSnapshot(world, blockPos, placeBlock); From 5caa2b6fcc6fda0c0f96fcef6774f64ccf155c60 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Wed, 26 Aug 2020 17:42:43 +0200 Subject: [PATCH 14/14] placement dir improvements --- .../thetadev/constructionwand/basics/WandUtil.java | 2 +- .../java/thetadev/constructionwand/job/WandJob.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/thetadev/constructionwand/basics/WandUtil.java b/src/main/java/thetadev/constructionwand/basics/WandUtil.java index e902b52..c4e05a1 100644 --- a/src/main/java/thetadev/constructionwand/basics/WandUtil.java +++ b/src/main/java/thetadev/constructionwand/basics/WandUtil.java @@ -41,6 +41,6 @@ public class WandUtil } public static Vec3d entityPositionVec(Entity entity) { - return new Vec3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight()/2, entity.getPosZ()); + return new Vec3d(entity.posX, entity.posY - entity.getYOffset() + entity.getHeight()/2, entity.posZ); } } diff --git a/src/main/java/thetadev/constructionwand/job/WandJob.java b/src/main/java/thetadev/constructionwand/job/WandJob.java index 5a1df28..e084dee 100644 --- a/src/main/java/thetadev/constructionwand/job/WandJob.java +++ b/src/main/java/thetadev/constructionwand/job/WandJob.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.state.IProperty; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.state.properties.SlabType; import net.minecraft.stats.Stats; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; @@ -197,7 +198,7 @@ public abstract class WandJob if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) return false; // No entities in area? - AxisAlignedBB blockBB = new AxisAlignedBB(pos); + AxisAlignedBB blockBB = blockState.getCollisionShape(world, pos).getBoundingBox().offset(pos); return world.getEntitiesWithinAABB(LivingEntity.class, blockBB, EntityPredicates.NOT_SPECTATING).isEmpty(); } @@ -215,7 +216,7 @@ public abstract class WandJob BlockState supportingBlock = placeSnapshot.supportingBlock; - if(targetDirection && placeBlock.getBlock() == supportingBlock.getBlock()) { + if(targetDirection) { // Block properties to be copied (alignment/rotation properties) for(IProperty property : new IProperty[] { BlockStateProperties.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP, @@ -225,6 +226,12 @@ public abstract class WandJob placeBlock = placeBlock.with(property, supportingBlock.get(property)); } } + + // Dont dupe double slabs + if(supportingBlock.has(BlockStateProperties.SLAB_TYPE)) { + SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE); + if(slabType != SlabType.DOUBLE) placeBlock = placeBlock.with(BlockStateProperties.SLAB_TYPE, slabType); + } } // Abort if placeEvent is canceled BlockSnapshot snapshot = new BlockSnapshot(world, blockPos, placeBlock);