diff --git a/build.gradle b/build.gradle index 3f7c4a9..4ce67bf 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.1' +version = '1.14-1.1' 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,13 @@ 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.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.15-387.455:api") - - runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455") + compileOnly fg.deobf("vazkii.botania:Botania:r1.11-379.354:api") + 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 60a4660..b72d660 100644 --- a/src/main/java/thetadev/constructionwand/client/KeyEvents.java +++ b/src/main/java/thetadev/constructionwand/client/KeyEvents.java @@ -29,9 +29,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+"replace", 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 = { @@ -42,8 +44,8 @@ public class KeyEvents private boolean ctrlPressed; public KeyEvents() { - for(KeyBinding key : keys) ClientRegistry.registerKeyBinding(key); - ctrlPressed = false; + ClientRegistry.registerKeyBinding(WAND_KEY); + ctrlPressed = false; } @SubscribeEvent @@ -52,10 +54,12 @@ public class KeyEvents if(player == null) return; if(WandUtil.holdingWand(player) == null) return; - for(int i=0; i undoBlocks; @SubscribeEvent - public void renderBlockHighlight(DrawHighlightEvent event) + public void renderBlockHighlight(DrawBlockHighlightEvent event) { if(event.getTarget().getType() != RayTraceResult.Type.BLOCK) return; @@ -54,24 +52,48 @@ public class RenderBlockPreview if(blocks == null || blocks.isEmpty()) return; - renderBlockList(blocks, event.getMatrix(), event.getBuffers(), colorR, colorG, colorB); + for(BlockPos block : blocks) { + + double partialTicks = event.getPartialTicks(); + 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); + //WorldRenderer.drawSelectionBoundingBox(aabb, colorR, colorG, colorB, 0.4F); + drawBoundingBox(aabb, colorR, colorG, colorB, 0.4F); + } event.setCanceled(true); } - private void renderBlockList(LinkedList blocks, MatrixStack ms, IRenderTypeBuffer buffer, float red, float green, float blue) { - double renderPosX = Minecraft.getInstance().getRenderManager().info.getProjectedView().getX(); - double renderPosY = Minecraft.getInstance().getRenderManager().info.getProjectedView().getY(); - double renderPosZ = Minecraft.getInstance().getRenderManager().info.getProjectedView().getZ(); + 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); - ms.push(); - ms.translate(-renderPosX, -renderPosY, -renderPosZ); + //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(); - for(BlockPos block : blocks) { - AxisAlignedBB aabb = new AxisAlignedBB(block); - IVertexBuilder lineBuilder = buffer.getBuffer(RenderTypes.TRANSLUCENT_LINES); - WorldRenderer.drawBoundingBox(ms, lineBuilder, aabb, red, green, blue, 0.4F); - } - ms.pop(); + tessellator.draw(); } } 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 af0af45..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); @@ -74,7 +74,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 @@ -87,13 +87,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); } } @@ -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)); } } 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; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 1f64012..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 @@ -44,7 +44,7 @@ This is my first minecraft mod. May the odds be ever in your favor. # 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 @@ -53,6 +53,6 @@ This is my first minecraft mod. May the odds be ever in your favor. [[dependencies.constructionwand]] modId="minecraft" mandatory=true - versionRange="[1.15.2]" + versionRange="[1.14.4]" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/constructionwand/lang/de_de.json b/src/main/resources/assets/constructionwand/lang/de_de.json index e2f8adc..0db7b5c 100644 --- a/src/main/resources/assets/constructionwand/lang/de_de.json +++ b/src/main/resources/assets/constructionwand/lang/de_de.json @@ -5,6 +5,7 @@ "item.constructionwand.infinity_wand": "Stab der Unendlichkeit", "constructionwand.key.category": "Construction Wand", + "constructionwand.key.wand": "Ausrichtung (+SHIFT: Ersetzungsmodus)", "constructionwand.key.direction": "Ausrichtung", "constructionwand.key.replace": "Ersetzungsmodus", diff --git a/src/main/resources/assets/constructionwand/lang/en_us.json b/src/main/resources/assets/constructionwand/lang/en_us.json index 6c2d948..2451ee7 100644 --- a/src/main/resources/assets/constructionwand/lang/en_us.json +++ b/src/main/resources/assets/constructionwand/lang/en_us.json @@ -5,6 +5,7 @@ "item.constructionwand.infinity_wand": "Infinity Wand", "constructionwand.key.category": "Construction Wand", + "constructionwand.key.wand": "Place direction (+SHIFT: Replacement mode)", "constructionwand.key.direction": "Place direction", "constructionwand.key.replace": "Replacement mode",