Compare commits

...

58 commits

Author SHA1 Message Date
356a61816e Added TE White/Blacklist
Now triggers onBlockPlacedBy()
Fixed SecurityCraft bug
2020-12-06 19:45:13 +01:00
f6670138b4 Updated mod to V1.6
Added MC 1.16.4 support
Better direction lock descriptions
Removed stray English words in German translation
2020-11-06 16:29:38 +01:00
9f5398e0bc 1.14 update fixes 2020-09-29 23:50:11 +02:00
937742e4fd
Merge pull request #27 from Theta-Dev/update_1.5
Update 1.5 -> 1.4
2020-09-29 22:55:03 +02:00
bb8c7754d4
Merge branch '1.14' into update_1.5 2020-09-29 22:54:55 +02:00
2abea82c76
Merge branch '1.15' into update_1.5 2020-09-29 22:53:02 +02:00
b848742f90
Merge branch '1.16' into update_1.5 2020-09-29 22:47:29 +02:00
3aee9629df Fixed stack overflow when placing many connecting blocks (1.16) 2020-09-18 22:29:53 +02:00
d4be1e020a Fixed stack overflow when placing many connecting blocks 2020-09-18 22:08:45 +02:00
a966a47209 Merge remote-tracking branch 'origin/1.15' into 1.15
# Conflicts:
#	src/main/java/thetadev/constructionwand/job/WandJob.java
2020-09-18 22:02:53 +02:00
cb01f789cb Fixed stack overflow when placing many connecting blocks 2020-09-18 22:01:40 +02:00
4571faea01 Fixed stack overflow when placing many connecting blocks 2020-09-18 21:38:49 +02:00
a29ce8cc22 Fixed stack overflow when placing many connecting blocks 2020-09-18 21:32:42 +02:00
35ab23120f Changed readme 2020-09-18 13:09:56 +02:00
a0be0884f6 Changed readme 2020-09-18 13:08:19 +02:00
40a4df7a20 Changed readme 2020-09-18 13:06:12 +02:00
892bff42b5
Merge pull request #23 from Theta-Dev/update1.3
Update1.3 -> 1.14
2020-09-18 00:48:00 +02:00
896f321cc1 Updated version to 1.14 2020-09-18 00:47:36 +02:00
7b291d514f Changed botania version 2020-09-18 00:20:09 +02:00
e6e282427b
Merge pull request #22 from Theta-Dev/update1.3
Update1.3 -> 1.15
2020-09-18 00:16:41 +02:00
0ea9cfaf46 Changed version to 1.15 2020-09-18 00:16:15 +02:00
3003cdcf18 Merge branch '1.15' into update1.3 2020-09-18 00:15:17 +02:00
0d90de89cf
Removed duplicate forge declaration 2020-09-17 23:26:40 +02:00
fe89f27aaa Set direction default to TARGET 2020-09-17 23:19:19 +02:00
9aec266dd2 Set mc/forge version 2020-09-17 23:17:02 +02:00
0ca8f23b69
Merge pull request #21 from Theta-Dev/update1.3
Update1.3 -> 1.16
2020-09-17 23:03:50 +02:00
e4ca89680d
Merge branch '1.16' into update1.3 2020-09-17 23:03:42 +02:00
d87c7f7d1b fix exception with no-collision blocks 2020-08-27 00:10:38 +02:00
c99feca1ee
Merge pull request #19 from Theta-Dev/fix_collision
Fix collision
2020-08-26 23:57:32 +02:00
555d85f879
Merge branch '1.14' into fix_collision 2020-08-26 23:57:23 +02:00
87ab64675f
Merge pull request #18 from Theta-Dev/fix_collision
Fix collision
2020-08-26 23:56:00 +02:00
b9353126eb
Merge branch '1.15' into fix_collision 2020-08-26 23:55:52 +02:00
20b016dd57
Merge pull request #17 from Theta-Dev/fix_collision
Fix collision
2020-08-26 23:51:57 +02:00
95d3c504ba
Merge branch '1.16' into fix_collision 2020-08-26 23:51:47 +02:00
5caa2b6fcc placement dir improvements 2020-08-26 17:42:43 +02:00
4876683b07 placement dir improvements 2020-08-26 17:39:21 +02:00
64f947e535 Revert "Merge branch '1.16' into 1.15"
This reverts commit cd99733803, reversing
changes made to fa1587f269.
2020-08-26 17:24:31 +02:00
cd99733803 Merge branch '1.16' into 1.15 2020-08-26 17:20:13 +02:00
1186043bf3 placement dir improvements 2020-08-26 17:18:54 +02:00
c4e73e7a0a
Merge pull request #14 from Theta-Dev/1.15_1.2
1.2 Update - 1.14
2020-08-26 01:12:21 +02:00
97a037611c
Merge branch '1.14' into 1.15_1.2 2020-08-26 01:12:09 +02:00
fa1587f269
Merge pull request #13 from Theta-Dev/1.15_1.2
Update 1.2
2020-08-26 01:06:37 +02:00
e3918bc9bb
Update README.md 2020-08-15 21:10:51 +02:00
89fbd5313b
Update README.md 2020-08-03 21:56:39 +02:00
e3d6f161a2 more tiny fixes 2020-08-03 19:52:53 +02:00
2df50e381d Fixed tooltip not showing angel mode 2020-08-03 19:30:55 +02:00
c141eddd2d tiny fix 2020-08-03 19:06:24 +02:00
fc8bb4b6ef
Merge pull request #12 from Theta-Dev/1.15_update1.1
1.15 update1.1
2020-08-03 19:02:03 +02:00
6149dc4114
Merge branch '1.14' into 1.15_update1.1 2020-08-03 19:01:50 +02:00
dfbdb10a80 Fixed key events 2020-08-03 00:57:48 +02:00
bab43266a6
Merge pull request #6 from Theta-Dev/upd1.1
Mod update to 1.1
2020-08-03 00:13:15 +02:00
ce9673ee87
Merge branch '1.14' into upd1.1 2020-08-03 00:12:05 +02:00
37dd871056
Merge pull request #5 from Theta-Dev/1.15
1.15
2020-08-03 00:06:08 +02:00
493861f8c9 Improved Preview Renderer 2020-08-02 18:09:42 +02:00
d3eaa22505 Ported to 1.14 2020-08-02 17:41:30 +02:00
36fa9efb32 Changed version to 1.14 2020-08-02 16:59:41 +02:00
c96feedb91 Changed version to 1.14 2020-08-02 16:56:49 +02:00
3f067cec30
Merge pull request #4 from Theta-Dev/1.15
Update mods.toml
2020-08-02 16:50:43 +02:00
28 changed files with 210 additions and 183 deletions

1
.gitignore vendored
View file

@ -25,3 +25,4 @@ run
forge*changelog.txt forge*changelog.txt
.cache .cache
logs

View file

@ -60,3 +60,19 @@ SHIFT+Right clicking empty space opens the option screen of your wand.
- Look at your statisics to see how many blocks you have placed using your wand - 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. - **1.16+ only:** The Infinity Wand won't burn in lava just like netherite gear.
## Contributions and #Hacktoberfest
As #Hacktoberfest now requires repo owners to opt in, I added the tag to this repository.
I'd really appreciate translations. Currently ConstructionWand only has English and German, so if you speak any other language you can help translate the mod and add a new language file under `src/main/resources/assets/constructionwand/lang/`.
## TileEntity Blacklist
Some modded TileEntitys can cause issues when placed using a wand. They may turn into invisible and unremovable ghost blocks,
become unbreakable or cause other unwanted effects.
That's why I've included a Black/Whitelist system
for TileEntities in CW Version 1.7. Chisels&Bits blocks are blacklisted by default. There are probably a few other tile entities
from other mods out there which may cause issues as well. If you find some of them you can tell me by creating
an issue, commenting on Curse or editing the default blacklist yourself
(it is located at https://github.com/Theta-Dev/ConstructionWand/blob/1.16.2/src/main/java/thetadev/constructionwand/basics/ConfigServer.java#L28)
and making a PR.

View file

@ -97,13 +97,19 @@ dependencies {
name : "forge", name : "forge",
version: "${project.mcversion}-${project.forgeversion}" version: "${project.mcversion}-${project.forgeversion}"
]) ])
/*
compileOnly fg.deobf([ compileOnly fg.deobf([
group: "vazkii.botania", group: "vazkii.botania",
name: "Botania", name: "Botania",
version: "${project.botania}", version: "${project.botania}",
classifier: "api" classifier: "api"
]) ])*/
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.11-379.354")
} }
jar { jar {

View file

@ -4,11 +4,11 @@ org.gradle.daemon=false
author=thetadev author=thetadev
modid=constructionwand modid=constructionwand
mcversion=1.16.2 mcversion=1.14.4
forgeversion=33.0.60 forgeversion=28.2.23
mcp_mappings=20200723-1.16.1 mcp_mappings=20190719-1.14.3
botania=1.16.2-405 botania=r1.11-379.354
version_major=1 version_major=1
version_minor=5 version_minor=7

View file

@ -11,7 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"tag": "minecraft:stone_tool_materials" "tag": "forge:cobblestone"
} }
] ]
} }

View file

@ -7,7 +7,7 @@
], ],
"key": { "key": {
"X": { "X": {
"tag": "minecraft:stone_tool_materials" "tag": "forge:cobblestone"
}, },
"#": { "#": {
"tag": "forge:rods/wooden" "tag": "forge:rods/wooden"

View file

@ -80,7 +80,6 @@ public class ConstructionWand
{ {
renderBlockPreview = new RenderBlockPreview(); renderBlockPreview = new RenderBlockPreview();
MinecraftForge.EVENT_BUS.register(renderBlockPreview); MinecraftForge.EVENT_BUS.register(renderBlockPreview);
ModItems.registerModelProperties();
} }
public static ResourceLocation loc(String name) { public static ResourceLocation loc(String name) {

View file

@ -10,6 +10,13 @@ public class ConfigClient
public static final ForgeConfigSpec.BooleanValue SHIFTCTRL_GUI; public static final ForgeConfigSpec.BooleanValue SHIFTCTRL_GUI;
static { static {
BUILDER.comment("This is the Client config for ConstructionWand.",
"If you're not familiar with Forge's new split client/server config, let me explain:",
"Client config is stored in the /config folder and only contains client specific settings like graphics and keybinds.",
"Mod behavior is configured in the Server config, which is world-specific and thus located",
"in the /saves/myworld/serverconfig folder. If you want to change the serverconfig for all",
"new worlds, copy the config files in the /defaultconfigs folder.");
BUILDER.push("keys"); BUILDER.push("keys");
BUILDER.comment("Press SHIFT+CTRL instead of SHIFT for changing wand mode/direction lock"); BUILDER.comment("Press SHIFT+CTRL instead of SHIFT for changing wand mode/direction lock");
SHIFTCTRL_MODE = BUILDER.define("ShiftCtrl", false); SHIFTCTRL_MODE = BUILDER.define("ShiftCtrl", false);

View file

@ -3,7 +3,6 @@ package thetadev.constructionwand.basics;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemTier; import net.minecraft.item.ItemTier;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import thetadev.constructionwand.items.ItemWand;
import thetadev.constructionwand.items.ModItems; import thetadev.constructionwand.items.ModItems;
import java.util.Arrays; import java.util.Arrays;
@ -24,6 +23,10 @@ public class ConfigServer
"minecraft:dirt;minecraft:grass_block;minecraft:coarse_dirt;minecraft:podzol;minecraft:mycelium;minecraft:farmland;minecraft:grass_path" "minecraft:dirt;minecraft:grass_block;minecraft:coarse_dirt;minecraft:podzol;minecraft:mycelium;minecraft:farmland;minecraft:grass_path"
}; };
public static final ForgeConfigSpec.BooleanValue TE_WHITELIST;
public static final ForgeConfigSpec.ConfigValue<List<?>> TE_LIST;
private static final String[] TE_LIST_DEFAULT = {"chiselsandbits"};
private static final HashMap<Item, WandProperties> wandProperties = new HashMap<>(); private static final HashMap<Item, WandProperties> wandProperties = new HashMap<>();
public static WandProperties getWandProperties(Item wand) { public static WandProperties getWandProperties(Item wand) {
@ -73,6 +76,13 @@ public class ConfigServer
} }
static { static {
BUILDER.comment("This is the Server config for ConstructionWand.",
"If you're not familiar with Forge's new split client/server config, let me explain:",
"Client config is stored in the /config folder and only contains client specific settings like graphics and keybinds.",
"Mod behavior is configured in the Server config, which is world-specific and thus located",
"in the /saves/myworld/serverconfig folder. If you want to change the serverconfig for all",
"new worlds, copy the config files in the /defaultconfigs folder.");
new WandProperties(BUILDER, ModItems.WAND_STONE, ItemTier.STONE.getMaxUses(), 9, 0); new WandProperties(BUILDER, ModItems.WAND_STONE, ItemTier.STONE.getMaxUses(), 9, 0);
new WandProperties(BUILDER, ModItems.WAND_IRON, ItemTier.IRON.getMaxUses(), 27, 1); new WandProperties(BUILDER, ModItems.WAND_IRON, ItemTier.IRON.getMaxUses(), 27, 1);
new WandProperties(BUILDER, ModItems.WAND_DIAMOND, ItemTier.DIAMOND.getMaxUses(), 128, 4); new WandProperties(BUILDER, ModItems.WAND_DIAMOND, ItemTier.DIAMOND.getMaxUses(), 128, 4);
@ -90,6 +100,14 @@ public class ConfigServer
BUILDER.comment("Blocks to treat equally when in Similar mode. Enter block IDs seperated by ;"); BUILDER.comment("Blocks to treat equally when in Similar mode. Enter block IDs seperated by ;");
SIMILAR_BLOCKS = BUILDER.defineList("SimilarBlocks", Arrays.asList(SIMILAR_BLOCKS_DEFAULT), obj -> true); SIMILAR_BLOCKS = BUILDER.defineList("SimilarBlocks", Arrays.asList(SIMILAR_BLOCKS_DEFAULT), obj -> true);
BUILDER.pop(); BUILDER.pop();
BUILDER.push("tileentity");
BUILDER.comment("White/Blacklist for Tile Entities. Allow/Prevent blocks with TEs from being placed by wand.",
"You can either add block ids like minecraft:chest or mod ids like minecraft");
TE_LIST = BUILDER.defineList("TEList", Arrays.asList(TE_LIST_DEFAULT), obj -> true);
BUILDER.comment("If set to TRUE, treat TEList as a whitelist, otherwise blacklist");
TE_WHITELIST = BUILDER.define("TEWhitelist", false);
BUILDER.pop();
} }
public static final ForgeConfigSpec SPEC = BUILDER.build(); public static final ForgeConfigSpec SPEC = BUILDER.build();

View file

@ -1,5 +1,6 @@
package thetadev.constructionwand.basics; package thetadev.constructionwand.basics;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -7,7 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.Vec3d;
import thetadev.constructionwand.ConstructionWand; import thetadev.constructionwand.ConstructionWand;
import thetadev.constructionwand.items.ItemWand; import thetadev.constructionwand.items.ItemWand;
@ -37,16 +38,8 @@ public class WandUtil
return null; return null;
} }
public static BlockPos playerPos(PlayerEntity player) { public static Vec3d entityPositionVec(Entity entity) {
return new BlockPos(player.getPositionVec()); return new Vec3d(entity.posX, entity.posY - entity.getYOffset() + entity.getHeight()/2, entity.posZ);
}
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 List<ItemStack> getHotbar(PlayerEntity player) { public static List<ItemStack> getHotbar(PlayerEntity player) {
@ -72,4 +65,19 @@ public class WandUtil
public static int maxRange(BlockPos p1, BlockPos p2) { public static int maxRange(BlockPos p1, BlockPos p2) {
return Math.max(Math.abs(p1.getX() - p2.getX()), Math.abs(p1.getZ() - p2.getZ())); return Math.max(Math.abs(p1.getX() - p2.getX()), Math.abs(p1.getZ() - p2.getZ()));
} }
public static boolean isTEAllowed(BlockState state) {
if(!state.hasTileEntity()) return true;
ResourceLocation name = state.getBlock().getRegistryName();
if(name == null) return false;
String fullId = name.toString();
String modId = name.getNamespace();
boolean inList = ConfigServer.TE_LIST.get().contains(fullId) || ConfigServer.TE_LIST.get().contains(modId);
boolean isWhitelist = ConfigServer.TE_WHITELIST.get();
return isWhitelist == inList;
}
} }

View file

@ -11,7 +11,8 @@ import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import thetadev.constructionwand.ConstructionWand; import thetadev.constructionwand.ConstructionWand;
import thetadev.constructionwand.basics.*; import thetadev.constructionwand.basics.ConfigClient;
import thetadev.constructionwand.basics.WandUtil;
import thetadev.constructionwand.basics.option.WandOptions; import thetadev.constructionwand.basics.option.WandOptions;
import thetadev.constructionwand.items.ItemWand; import thetadev.constructionwand.items.ItemWand;
import thetadev.constructionwand.network.PacketQueryUndo; import thetadev.constructionwand.network.PacketQueryUndo;

View file

@ -1,11 +1,9 @@
package thetadev.constructionwand.client; package thetadev.constructionwand.client;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -13,7 +11,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; 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 net.minecraftforge.eventbus.api.SubscribeEvent;
import thetadev.constructionwand.basics.WandUtil; import thetadev.constructionwand.basics.WandUtil;
import thetadev.constructionwand.job.WandJob; import thetadev.constructionwand.job.WandJob;
@ -26,7 +24,7 @@ public class RenderBlockPreview
public Set<BlockPos> undoBlocks; public Set<BlockPos> undoBlocks;
@SubscribeEvent @SubscribeEvent
public void renderBlockHighlight(DrawHighlightEvent event) public void renderBlockHighlight(DrawBlockHighlightEvent event)
{ {
if(event.getTarget().getType() != RayTraceResult.Type.BLOCK) return; if(event.getTarget().getType() != RayTraceResult.Type.BLOCK) return;
@ -54,24 +52,46 @@ public class RenderBlockPreview
if(blocks == null || blocks.isEmpty()) return; 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);
drawBoundingBox(aabb, colorR, colorG, colorB, 0.4F);
}
event.setCanceled(true); event.setCanceled(true);
} }
private void renderBlockList(Set<BlockPos> blocks, MatrixStack ms, IRenderTypeBuffer buffer, float red, float green, float blue) { private static void drawBoundingBox(AxisAlignedBB box, float red, float green, float blue, float alpha) {
double renderPosX = Minecraft.getInstance().getRenderManager().info.getProjectedView().getX(); Tessellator tessellator = Tessellator.getInstance();
double renderPosY = Minecraft.getInstance().getRenderManager().info.getProjectedView().getY(); BufferBuilder buffer = tessellator.getBuffer();
double renderPosZ = Minecraft.getInstance().getRenderManager().info.getProjectedView().getZ(); buffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
ms.push(); //Base
ms.translate(-renderPosX, -renderPosY, -renderPosZ); 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) { tessellator.draw();
AxisAlignedBB aabb = new AxisAlignedBB(block);
IVertexBuilder lineBuilder = buffer.getBuffer(RenderTypes.TRANSLUCENT_LINES);
WorldRenderer.drawBoundingBox(ms, lineBuilder, aabb, red, green, blue, 0.4F);
}
ms.pop();
} }
} }

View file

@ -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("always", 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
);
}
}

View file

@ -1,6 +1,5 @@
package thetadev.constructionwand.client; package thetadev.constructionwand.client;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.widget.button.Button;
@ -13,10 +12,13 @@ import thetadev.constructionwand.basics.option.IOption;
import thetadev.constructionwand.basics.option.WandOptions; import thetadev.constructionwand.basics.option.WandOptions;
import thetadev.constructionwand.network.PacketWandOption; import thetadev.constructionwand.network.PacketWandOption;
import java.util.HashMap;
public class ScreenWand extends Screen public class ScreenWand extends Screen
{ {
private final ItemStack wand; private final ItemStack wand;
private final WandOptions wandOptions; private final WandOptions wandOptions;
private final HashMap<IOption<?>, Button> optionButtons;
private static final int BUTTON_WIDTH = 160; private static final int BUTTON_WIDTH = 160;
private static final int BUTTON_HEIGHT = 20; private static final int BUTTON_HEIGHT = 20;
@ -32,11 +34,13 @@ public class ScreenWand extends Screen
super(new StringTextComponent("ScreenWand")); super(new StringTextComponent("ScreenWand"));
this.wand = wand; this.wand = wand;
wandOptions = new WandOptions(wand); wandOptions = new WandOptions(wand);
optionButtons = new HashMap<>();
} }
@Override @Override
public void init(Minecraft minecraft, int width, int height) { public void init(Minecraft minecraft, int width, int height) {
super.init(minecraft, width, height); super.init(minecraft, width, height);
optionButtons.clear();
createButton(0, 0, wandOptions.mode); createButton(0, 0, wandOptions.mode);
createButton(0, 1, wandOptions.lock); createButton(0, 1, wandOptions.lock);
@ -47,33 +51,35 @@ public class ScreenWand extends Screen
} }
@Override @Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { public void render(int mouseX, int mouseY, float partialTicks) {
renderBackground(matrixStack); renderBackground();
super.render(matrixStack, mouseX, mouseY, partialTicks); super.render(mouseX, mouseY, partialTicks);
drawCenteredString(matrixStack, font, wand.getDisplayName(), width/2, height/2 - FIELD_HEIGHT/2 - SPACING_HEIGHT, 16777215); drawCenteredString(font, wand.getDisplayName().getFormattedText(), width/2, height/2 - FIELD_HEIGHT/2 - SPACING_HEIGHT, 16777215);
optionButtons.forEach((opt, but) -> drawTooltip(mouseX, mouseY, opt, but));
} }
@Override @Override
public boolean charTyped(char character, int code) { public boolean charTyped(char character, int code) {
if(character == 'e') closeScreen(); if(character == 'e') onClose();
return super.charTyped(character, code); return super.charTyped(character, code);
} }
private void createButton(int cx, int cy, IOption<?> option) { private void createButton(int cx, int cy, IOption<?> option) {
Button button = new Button(getX(cx), getY(cy), BUTTON_WIDTH, BUTTON_HEIGHT, getButtonLabel(option), bt -> clickButton(bt, option), (bt, ms, x, y) -> drawTooltip(ms, x, y, option)); Button button = new Button(getX(cx), getY(cy), BUTTON_WIDTH, BUTTON_HEIGHT, getButtonLabel(option).getFormattedText(), bt -> clickButton(bt, option));
button.active = option.isEnabled(); button.active = option.isEnabled();
addButton(button); addButton(button);
optionButtons.put(option, button);
} }
private void clickButton(Button button, IOption<?> option) { private void clickButton(Button button, IOption<?> option) {
option.next(); option.next();
ConstructionWand.instance.HANDLER.sendToServer(new PacketWandOption(option, false)); ConstructionWand.instance.HANDLER.sendToServer(new PacketWandOption(option, false));
button.setMessage(getButtonLabel(option)); button.setMessage(getButtonLabel(option).getFormattedText());
} }
private void drawTooltip(MatrixStack matrixStack, int mouseX, int mouseY, IOption<?> option) { private void drawTooltip(int mouseX, int mouseY, IOption<?> option, Button button) {
if(isMouseOver(mouseX, mouseY)) { if(button.isHovered()) {
renderTooltip(matrixStack, new TranslationTextComponent(option.getDescTranslation()), mouseX, mouseY); renderTooltip(new TranslationTextComponent(option.getDescTranslation()).getFormattedText(), mouseX, mouseY);
} }
} }
@ -86,6 +92,6 @@ public class ScreenWand extends Screen
} }
private ITextComponent getButtonLabel(IOption<?> option) { private ITextComponent getButtonLabel(IOption<?> option) {
return new TranslationTextComponent(option.getKeyTranslation()).append(new TranslationTextComponent(option.getValueTranslation())); return new TranslationTextComponent(option.getKeyTranslation()).appendSibling(new TranslationTextComponent(option.getValueTranslation()));
} }
} }

View file

@ -3,7 +3,7 @@ package thetadev.constructionwand.data;
import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ITag; import net.minecraft.tags.Tag;
import net.minecraft.util.IItemProvider; import net.minecraft.util.IItemProvider;
public class Inp public class Inp
@ -21,7 +21,7 @@ public class Inp
public static Inp fromItem(IItemProvider in) { public static Inp fromItem(IItemProvider in) {
return new Inp(in.asItem().getRegistryName().getPath(), Ingredient.fromItems(in), ItemPredicate.Builder.create().item(in).build()); return new Inp(in.asItem().getRegistryName().getPath(), Ingredient.fromItems(in), ItemPredicate.Builder.create().item(in).build());
} }
public static Inp fromTag(ITag.INamedTag<Item> in) { public static Inp fromTag(Tag<Item> in) {
return new Inp(in.getName().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build()); return new Inp(in.getId().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build());
} }
} }

View file

@ -4,7 +4,6 @@ import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider; import net.minecraft.data.RecipeProvider;
import net.minecraft.data.ShapedRecipeBuilder; import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.IItemProvider; import net.minecraft.util.IItemProvider;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import thetadev.constructionwand.ConstructionWand; import thetadev.constructionwand.ConstructionWand;
@ -20,7 +19,7 @@ public class RecipeGenerator extends RecipeProvider
@Override @Override
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) { protected void registerRecipes(Consumer<IFinishedRecipe> 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_IRON, Inp.fromTag(Tags.Items.INGOTS_IRON));
wandRecipe(consumer, ModItems.WAND_DIAMOND, Inp.fromTag(Tags.Items.GEMS_DIAMOND)); wandRecipe(consumer, ModItems.WAND_DIAMOND, Inp.fromTag(Tags.Items.GEMS_DIAMOND));
wandRecipe(consumer, ModItems.WAND_INFINITY, Inp.fromTag(Tags.Items.NETHER_STARS)); wandRecipe(consumer, ModItems.WAND_INFINITY, Inp.fromTag(Tags.Items.NETHER_STARS));

View file

@ -11,6 +11,7 @@ import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
@ -33,6 +34,7 @@ public abstract class ItemWand extends Item
public ItemWand(String name, Item.Properties properties) { public ItemWand(String name, Item.Properties properties) {
super(properties.group(ItemGroup.TOOLS)); super(properties.group(ItemGroup.TOOLS));
setRegistryName(ConstructionWand.loc(name)); setRegistryName(ConstructionWand.loc(name));
addPropertyOverride(new ResourceLocation(ConstructionWand.MODID, "wand_mode"), (stack, worldIn, entityIn) -> getWandMode(stack));
} }
@Override @Override
@ -60,14 +62,14 @@ public abstract class ItemWand extends Item
ItemStack stack = player.getHeldItem(hand); ItemStack stack = player.getHeldItem(hand);
if(!player.isSneaking()) { if(!player.isSneaking()) {
if(world.isRemote) return ActionResult.resultFail(stack); if(world.isRemote) return new ActionResult<>(ActionResultType.FAIL, stack);
// Right click: Place angel block // Right click: Place angel block
//ConstructionWand.LOGGER.debug("Place angel block"); //ConstructionWand.LOGGER.debug("Place angel block");
WandJob job = new AngelJob(player, world, stack); 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);
} }
return ActionResult.resultFail(stack); return new ActionResult<>(ActionResultType.FAIL, stack);
} }
@Override @Override
@ -103,26 +105,26 @@ public abstract class ItemWand extends Item
if(Screen.hasShiftDown()) { if(Screen.hasShiftDown()) {
for(int i=1; i<options.allOptions.length; i++) { for(int i=1; i<options.allOptions.length; i++) {
IOption<?> opt = options.allOptions[i]; IOption<?> opt = options.allOptions[i];
lines.add(new TranslationTextComponent(opt.getKeyTranslation()).mergeStyle(TextFormatting.AQUA) lines.add(new TranslationTextComponent(opt.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA)
.append(new TranslationTextComponent(opt.getValueTranslation()).mergeStyle(TextFormatting.GRAY)) .appendSibling(new TranslationTextComponent(opt.getValueTranslation()).applyTextStyle(TextFormatting.GRAY))
); );
} }
} }
else { else {
IOption<?> opt = options.allOptions[0]; IOption<?> opt = options.allOptions[0];
lines.add(new TranslationTextComponent(langTooltip + "blocks", getLimit()).mergeStyle(TextFormatting.GRAY)); lines.add(new TranslationTextComponent(langTooltip + "blocks", getLimit()).applyTextStyle(TextFormatting.GRAY));
lines.add(new TranslationTextComponent(opt.getKeyTranslation()).mergeStyle(TextFormatting.AQUA) lines.add(new TranslationTextComponent(opt.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA)
.append(new TranslationTextComponent(opt.getValueTranslation()).mergeStyle(TextFormatting.WHITE))); .appendSibling(new TranslationTextComponent(opt.getValueTranslation()).applyTextStyle(TextFormatting.WHITE)));
lines.add(new TranslationTextComponent(langTooltip + "shift").mergeStyle(TextFormatting.AQUA)); lines.add(new TranslationTextComponent(langTooltip + "shift").applyTextStyle(TextFormatting.AQUA));
} }
} }
public static void optionMessage(PlayerEntity player, IOption<?> option) { public static void optionMessage(PlayerEntity player, IOption<?> option) {
player.sendStatusMessage( player.sendStatusMessage(
new TranslationTextComponent(option.getKeyTranslation()).mergeStyle(TextFormatting.AQUA) new TranslationTextComponent(option.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA)
.append(new TranslationTextComponent(option.getValueTranslation()).mergeStyle(TextFormatting.WHITE)) .appendSibling(new TranslationTextComponent(option.getValueTranslation()).applyTextStyle(TextFormatting.WHITE))
.append(new StringTextComponent(" - ").mergeStyle(TextFormatting.GRAY)) .appendSibling(new StringTextComponent(" - ").applyTextStyle(TextFormatting.GRAY))
.append(new TranslationTextComponent(option.getDescTranslation()).mergeStyle(TextFormatting.WHITE)) .appendSibling(new TranslationTextComponent(option.getDescTranslation()).applyTextStyle(TextFormatting.WHITE))
, true); , true);
} }
} }

View file

@ -2,12 +2,7 @@ package thetadev.constructionwand.items;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.IItemTier; import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Properties;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.ResourceLocation;
import thetadev.constructionwand.basics.ConfigServer; import thetadev.constructionwand.basics.ConfigServer;
public class ItemWandBasic extends ItemWand public class ItemWandBasic extends ItemWand

View file

@ -1,7 +1,6 @@
package thetadev.constructionwand.items; package thetadev.constructionwand.items;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import thetadev.constructionwand.basics.ConfigServer; import thetadev.constructionwand.basics.ConfigServer;
@ -9,7 +8,7 @@ public class ItemWandInfinity extends ItemWand
{ {
public ItemWandInfinity(String name) public ItemWandInfinity(String name)
{ {
super(name, new Properties().maxStackSize(1).isBurnable()); super(name, new Properties().maxStackSize(1));
} }
@Override @Override

View file

@ -1,14 +1,11 @@
package thetadev.constructionwand.items; package thetadev.constructionwand.items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemModelsProperties;
import net.minecraft.item.ItemTier; import net.minecraft.item.ItemTier;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistryEntry;
import thetadev.constructionwand.basics.ConfigServer;
import thetadev.constructionwand.ConstructionWand; import thetadev.constructionwand.ConstructionWand;
@Mod.EventBusSubscriber(modid = ConstructionWand.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @Mod.EventBusSubscriber(modid = ConstructionWand.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
@ -26,13 +23,4 @@ public class ModItems
{ {
event.getRegistry().registerAll(WANDS); event.getRegistry().registerAll(WANDS);
} }
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)
);
}
}
} }

View file

@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; 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 net.minecraft.world.World;
import thetadev.constructionwand.basics.ConfigServer; import thetadev.constructionwand.basics.ConfigServer;
import thetadev.constructionwand.basics.WandUtil; import thetadev.constructionwand.basics.WandUtil;
@ -15,10 +15,10 @@ import thetadev.constructionwand.basics.option.WandOptions;
public class AngelJob extends WandJob public class AngelJob extends WandJob
{ {
public AngelJob(PlayerEntity player, World world, ItemStack wand) { 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); return Direction.getFacingFromVector(vector.x, vector.y, vector.z);
} }
@ -28,9 +28,9 @@ public class AngelJob extends WandJob
if(!player.isCreative() && !ConfigServer.ANGEL_FALLING.get() && player.fallDistance > 10) return; if(!player.isCreative() && !ConfigServer.ANGEL_FALLING.get() && player.fallDistance > 10) return;
Vector3d playerVec = WandUtil.entityPositionVec(player); Vec3d playerVec = WandUtil.entityPositionVec(player);
Vector3d lookVec = player.getLookVec().mul(2, 2, 2); Vec3d lookVec = player.getLookVec().mul(2, 2, 2);
Vector3d placeVec = playerVec.add(lookVec); Vec3d placeVec = playerVec.add(lookVec);
BlockPos currentPos = new BlockPos(placeVec); BlockPos currentPos = new BlockPos(placeVec);

View file

@ -140,7 +140,7 @@ public class UndoHistory
// Play teleport sound // Play teleport sound
SoundEvent sound = SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT; 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; return true;
} }

View file

@ -6,8 +6,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.Vec3d;
import thetadev.constructionwand.basics.WandUtil;
public class WandItemUseContext extends BlockItemUseContext public class WandItemUseContext extends BlockItemUseContext
{ {
@ -15,10 +14,9 @@ public class WandItemUseContext extends BlockItemUseContext
super(job.world, job.player, Hand.MAIN_HAND, new ItemStack(item), new BlockRayTraceResult(getBlockHitVec(job, pos), job.rayTraceResult.getFace(), pos, false)); super(job.world, job.player, Hand.MAIN_HAND, new ItemStack(item), new BlockRayTraceResult(getBlockHitVec(job, pos), job.rayTraceResult.getFace(), pos, false));
} }
private static Vector3d getBlockHitVec(WandJob job, BlockPos pos) { private static Vec3d getBlockHitVec(WandJob job, BlockPos pos) {
Vector3d hitVec = job.rayTraceResult.getHitVec(); // Absolute coords of hit target 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
Vector3d blockDelta = WandUtil.blockPosVec(job.rayTraceResult.getPos()).subtract(WandUtil.blockPosVec(pos)); // Vector between start and current block
return blockDelta.add(hitVec); // Absolute coords of current block hit target return blockDelta.add(hitVec); // Absolute coords of current block hit target
} }

View file

@ -4,7 +4,7 @@ import net.minecraft.block.*;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*; 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.BlockStateProperties;
import net.minecraft.state.properties.SlabType; import net.minecraft.state.properties.SlabType;
import net.minecraft.stats.Stats; import net.minecraft.stats.Stats;
@ -247,6 +247,9 @@ public abstract class WandJob
blockState = Block.getValidBlockForPosition(blockState, world, pos); blockState = Block.getValidBlockForPosition(blockState, world, pos);
if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) continue; if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) continue;
// Forbidden Tile Entity?
if(!WandUtil.isTEAllowed(blockState)) continue;
// No entities colliding? // No entities colliding?
VoxelShape shape = blockState.getCollisionShape(world, pos); VoxelShape shape = blockState.getCollisionShape(world, pos);
if(!shape.isEmpty()) { if(!shape.isEmpty()) {
@ -273,35 +276,35 @@ public abstract class WandJob
if(options.direction.get() == WandOptions.DIRECTION.TARGET) { if(options.direction.get() == WandOptions.DIRECTION.TARGET) {
// Block properties to be copied (alignment/rotation properties) // 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.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP,
BlockStateProperties.ROTATION_0_15, BlockStateProperties.AXIS, BlockStateProperties.HALF, BlockStateProperties.STAIRS_SHAPE}) BlockStateProperties.ROTATION_0_15, BlockStateProperties.AXIS, BlockStateProperties.HALF, BlockStateProperties.STAIRS_SHAPE})
{ {
if(supportingBlock.hasProperty(property) && placeBlock.hasProperty(property)) { if(supportingBlock.has(property) && placeBlock.has(property)) {
placeBlock = placeBlock.with(property, supportingBlock.get(property)); placeBlock = placeBlock.with(property, supportingBlock.get(property));
} }
} }
// Dont dupe double slabs // Dont dupe double slabs
if(supportingBlock.hasProperty(BlockStateProperties.SLAB_TYPE) && placeBlock.hasProperty(BlockStateProperties.SLAB_TYPE)) { if(supportingBlock.has(BlockStateProperties.SLAB_TYPE) && placeBlock.has(BlockStateProperties.SLAB_TYPE)) {
SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE); SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE);
if(slabType != SlabType.DOUBLE) placeBlock = placeBlock.with(BlockStateProperties.SLAB_TYPE, slabType); 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 // Place the block
if(!world.setBlockState(blockPos, placeBlock)) { if(!world.setBlockState(blockPos, placeBlock)) {
ConstructionWand.LOGGER.info("Block could not be placed"); ConstructionWand.LOGGER.info("Block could not be placed");
return false; return false;
} }
// Remove block if placeEvent is canceled // Call OnBlockPlaced method
BlockSnapshot snapshot = BlockSnapshot.create(world.func_234923_W_(), world, blockPos); placeBlock.getBlock().onBlockPlacedBy(world, blockPos, placeBlock, player, new ItemStack(placeSnapshot.item));
BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, placeBlock, player);
MinecraftForge.EVENT_BUS.post(placeEvent);
if(placeEvent.isCanceled()) {
world.removeBlock(blockPos, false);
return false;
}
// Update stats // Update stats
player.addStat(Stats.ITEM_USED.get(placeSnapshot.item)); player.addStat(Stats.ITEM_USED.get(placeSnapshot.item));
@ -342,10 +345,9 @@ public abstract class WandJob
} }
placeSnapshots = placed; placeSnapshots = placed;
// Play place sound
if(!placeSnapshots.isEmpty()) { if(!placeSnapshots.isEmpty()) {
SoundType sound = placeSnapshots.getFirst().block.getSoundType(); 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 // Add to job history for undo

View file

@ -6,7 +6,6 @@ import net.minecraftforge.fml.network.NetworkEvent;
import thetadev.constructionwand.ConstructionWand; import thetadev.constructionwand.ConstructionWand;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set; import java.util.Set;
import java.util.function.Supplier; import java.util.function.Supplier;

View file

@ -1,13 +1,13 @@
modLoader="javafml" modLoader="javafml"
loaderVersion="[33,)"
license="MIT License" license="MIT License"
loaderVersion="[28,)"
[[mods]] [[mods]]
modId="constructionwand" modId="constructionwand"
version="${file.jarVersion}" version="${file.jarVersion}"
displayName="Construction Wand" displayName="Construction Wand"
displayURL="https://github.com/Theta-Dev/ConstructionWand" #optional displayURL="https://github.com/Theta-Dev/ConstructionWand" #optional
logoFile="logo.png" #optional logoFile="logo.png"
authors="ThetaDev" #optional authors="ThetaDev"
description=''' description='''
Construction Wands make building easier! Construction Wands make building easier!
@ -20,12 +20,12 @@ This is my first minecraft mod. May the odds be ever in your favor.
[[dependencies.constructionwand]] [[dependencies.constructionwand]]
modId="forge" modId="forge"
mandatory=true mandatory=true
versionRange="[33,)" versionRange="[28,)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.constructionwand]] [[dependencies.constructionwand]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
versionRange="[1.16.2, 1.16.3]" versionRange="[1.14.4]"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"

View file

@ -15,13 +15,13 @@
"constructionwand.option.lock": "Beschränkung: ", "constructionwand.option.lock": "Beschränkung: ",
"constructionwand.option.lock.horizontal": "§aHorizontal", "constructionwand.option.lock.horizontal": "§aHorizontal",
"constructionwand.option.lock.horizontal.desc": "Erweitert nach §arechts/links§f. Baut nicht auf der Ober/Unterseite", "constructionwand.option.lock.horizontal.desc": "Baut eine horizontale Säule vor dem Originalblock",
"constructionwand.option.lock.vertical": "§aVertikal", "constructionwand.option.lock.vertical": "§aVertikal",
"constructionwand.option.lock.vertical.desc": "Erweitert nach §aoben/unten§f. Baut nicht auf der Ober/Unterseite", "constructionwand.option.lock.vertical.desc": "Baut eine vertikale Säule vor dem Originalblock",
"constructionwand.option.lock.northsouth": "§6North/South", "constructionwand.option.lock.northsouth": "§6Nord/Süd",
"constructionwand.option.lock.northsouth.desc": "Erweitert nach §aNorden/Süden§f. Baut nicht an den Seitenflächen", "constructionwand.option.lock.northsouth.desc": "Baut eine Reihe in NS-Richtung auf dem Originalblock",
"constructionwand.option.lock.eastwest": "§6East/West", "constructionwand.option.lock.eastwest": "§6Ost/West",
"constructionwand.option.lock.eastwest.desc": "Erweitert nach §aOsten/Westen§f. Baut nicht an den Seitenflächen", "constructionwand.option.lock.eastwest.desc": "Baut eine Reihe in OW-Richtung auf dem Originalblock",
"constructionwand.option.lock.nolock": "§cKeine", "constructionwand.option.lock.nolock": "§cKeine",
"constructionwand.option.lock.nolock.desc": "Erweitert in jede Richtung", "constructionwand.option.lock.nolock.desc": "Erweitert in jede Richtung",
@ -29,7 +29,7 @@
"constructionwand.option.direction.target": "§6Zielblock", "constructionwand.option.direction.target": "§6Zielblock",
"constructionwand.option.direction.target.desc": "Platziert Blöcke mit der selben Ausrichtung wie der Zielblock", "constructionwand.option.direction.target.desc": "Platziert Blöcke mit der selben Ausrichtung wie der Zielblock",
"constructionwand.option.direction.player": "§aSpieler", "constructionwand.option.direction.player": "§aSpieler",
"constructionwand.option.direction.player.desc": "Place blocks facing the player", "constructionwand.option.direction.player.desc": "Platziert Blöcke in der Richtung, auf die der Spieler zeigt",
"constructionwand.option.replace": "Ersetzen: ", "constructionwand.option.replace": "Ersetzen: ",
"constructionwand.option.replace.yes": "§aJa", "constructionwand.option.replace.yes": "§aJa",
@ -45,11 +45,11 @@
"constructionwand.option.match.any": "§cAlle", "constructionwand.option.match.any": "§cAlle",
"constructionwand.option.match.any.desc": "Erweitert alle Blöcke", "constructionwand.option.match.any.desc": "Erweitert alle Blöcke",
"constructionwand.option.random": "Zufall: ", "constructionwand.option.random": "Zufallsmodus: ",
"constructionwand.option.random.yes": "§aJa", "constructionwand.option.random.yes": "§aEin",
"constructionwand.option.random.yes.desc": "Platziere zufällige Blöcke aus der Hotbar", "constructionwand.option.random.yes.desc": "Platziere zufällige Blöcke aus der Hotbar",
"constructionwand.option.random.no": "§cNein", "constructionwand.option.random.no": "§cAus",
"constructionwand.option.random.no.desc": "Platziere Blöcke nicht zufällig", "constructionwand.option.random.no.desc": "Platziere Blöcke normal",
"stat.constructionwand.use_wand": "Blöcke mithilfe des Stabs platziert" "stat.constructionwand.use_wand": "Blöcke mithilfe des Stabs platziert"
} }

View file

@ -14,14 +14,14 @@
"constructionwand.option.mode.angel.desc": "Place behind blocks and in mid air", "constructionwand.option.mode.angel.desc": "Place behind blocks and in mid air",
"constructionwand.option.lock": "Restriction: ", "constructionwand.option.lock": "Restriction: ",
"constructionwand.option.lock.horizontal": "§aHorizontal", "constructionwand.option.lock.horizontal": "§aLeft/Right",
"constructionwand.option.lock.horizontal.desc": "Extend §aleft/right§f from the original block. No building on top/bottom face", "constructionwand.option.lock.horizontal.desc": "Build a horizontal column in front of the original block",
"constructionwand.option.lock.vertical": "§aVertical", "constructionwand.option.lock.vertical": "§aUp/Down",
"constructionwand.option.lock.vertical.desc": "Extend §aup/down§f from the original block. No building on top/bottom face", "constructionwand.option.lock.vertical.desc": "Build a vertical column in front of the original block",
"constructionwand.option.lock.northsouth": "§6North/South", "constructionwand.option.lock.northsouth": "§6North/South",
"constructionwand.option.lock.northsouth.desc": "Extend §anorth/south§f on top of the original block. No building on side faces", "constructionwand.option.lock.northsouth.desc": "Build a row in N/S direction on top of the original block",
"constructionwand.option.lock.eastwest": "§6East/West", "constructionwand.option.lock.eastwest": "§6East/West",
"constructionwand.option.lock.eastwest.desc": "Extend §aeast/west§f on top of the original block. No building on side faces", "constructionwand.option.lock.eastwest.desc": "Build a row in E/W direction on top of the original block",
"constructionwand.option.lock.nolock": "§cNone", "constructionwand.option.lock.nolock": "§cNone",
"constructionwand.option.lock.nolock.desc": "Extend from any side of the original block", "constructionwand.option.lock.nolock.desc": "Extend from any side of the original block",