diff --git a/.gitignore b/.gitignore index aa70068..faba627 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ run # Files from Forge MDK forge*changelog.txt -.cache \ No newline at end of file +.cache +logs \ No newline at end of file diff --git a/README.md b/README.md index bc211d2..891c507 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,20 @@ 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 -- **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. + +## 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. diff --git a/build.gradle b/build.gradle index f075063..4b42eae 100644 --- a/build.gradle +++ b/build.gradle @@ -104,6 +104,10 @@ dependencies { version: "${project.botania}", classifier: "api" ]) + + //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.botania:Botania:r1.15-387.455") } jar { @@ -137,4 +141,4 @@ publishing { url "file:///${project.projectDir}/mcmodsrepo" } } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index eec0280..6e6171f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,11 +4,11 @@ org.gradle.daemon=false author=thetadev modid=constructionwand -mcversion=1.16.2 -forgeversion=33.0.60 -mcp_mappings=20200723-1.16.1 +mcversion=1.15.2 +forgeversion=31.2.31 +mcp_mappings=20200514-1.15.1 -botania=1.16.2-405 +botania=r1.15-387.455 version_major=1 -version_minor=5 \ No newline at end of file +version_minor=7 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 e8db1fe..c129f7e 100644 --- a/src/main/java/thetadev/constructionwand/ConstructionWand.java +++ b/src/main/java/thetadev/constructionwand/ConstructionWand.java @@ -80,7 +80,6 @@ public class ConstructionWand { renderBlockPreview = new RenderBlockPreview(); MinecraftForge.EVENT_BUS.register(renderBlockPreview); - ModItems.registerModelProperties(); } public static ResourceLocation loc(String name) { diff --git a/src/main/java/thetadev/constructionwand/basics/ConfigClient.java b/src/main/java/thetadev/constructionwand/basics/ConfigClient.java index 60fd305..621f042 100644 --- a/src/main/java/thetadev/constructionwand/basics/ConfigClient.java +++ b/src/main/java/thetadev/constructionwand/basics/ConfigClient.java @@ -10,6 +10,13 @@ public class ConfigClient public static final ForgeConfigSpec.BooleanValue SHIFTCTRL_GUI; 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.comment("Press SHIFT+CTRL instead of SHIFT for changing wand mode/direction lock"); SHIFTCTRL_MODE = BUILDER.define("ShiftCtrl", false); diff --git a/src/main/java/thetadev/constructionwand/basics/ConfigServer.java b/src/main/java/thetadev/constructionwand/basics/ConfigServer.java index eb22814..003a265 100644 --- a/src/main/java/thetadev/constructionwand/basics/ConfigServer.java +++ b/src/main/java/thetadev/constructionwand/basics/ConfigServer.java @@ -3,7 +3,6 @@ package thetadev.constructionwand.basics; import net.minecraft.item.Item; import net.minecraft.item.ItemTier; import net.minecraftforge.common.ForgeConfigSpec; -import thetadev.constructionwand.items.ItemWand; import thetadev.constructionwand.items.ModItems; 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" }; + public static final ForgeConfigSpec.BooleanValue TE_WHITELIST; + public static final ForgeConfigSpec.ConfigValue> TE_LIST; + private static final String[] TE_LIST_DEFAULT = {"chiselsandbits"}; + private static final HashMap wandProperties = new HashMap<>(); public static WandProperties getWandProperties(Item wand) { @@ -73,6 +76,13 @@ public class ConfigServer } 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_IRON, ItemTier.IRON.getMaxUses(), 27, 1); 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 ;"); SIMILAR_BLOCKS = BUILDER.defineList("SimilarBlocks", Arrays.asList(SIMILAR_BLOCKS_DEFAULT), obj -> true); 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(); diff --git a/src/main/java/thetadev/constructionwand/basics/WandUtil.java b/src/main/java/thetadev/constructionwand/basics/WandUtil.java index 38b0687..f7f70cd 100644 --- a/src/main/java/thetadev/constructionwand/basics/WandUtil.java +++ b/src/main/java/thetadev/constructionwand/basics/WandUtil.java @@ -1,5 +1,6 @@ package thetadev.constructionwand.basics; +import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -7,7 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; 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.items.ItemWand; @@ -37,16 +38,8 @@ 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()); } public static List getHotbar(PlayerEntity player) { @@ -72,4 +65,19 @@ public class WandUtil public static int maxRange(BlockPos p1, BlockPos p2) { 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; + } } diff --git a/src/main/java/thetadev/constructionwand/client/ClientEvents.java b/src/main/java/thetadev/constructionwand/client/ClientEvents.java index 5e125aa..2d1facf 100644 --- a/src/main/java/thetadev/constructionwand/client/ClientEvents.java +++ b/src/main/java/thetadev/constructionwand/client/ClientEvents.java @@ -11,7 +11,8 @@ import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; 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.items.ItemWand; import thetadev.constructionwand.network.PacketQueryUndo; 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/client/ScreenWand.java b/src/main/java/thetadev/constructionwand/client/ScreenWand.java index bc312f1..2f3e68c 100644 --- a/src/main/java/thetadev/constructionwand/client/ScreenWand.java +++ b/src/main/java/thetadev/constructionwand/client/ScreenWand.java @@ -1,6 +1,5 @@ package thetadev.constructionwand.client; -import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; 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.network.PacketWandOption; +import java.util.HashMap; + public class ScreenWand extends Screen { private final ItemStack wand; private final WandOptions wandOptions; + private final HashMap, Button> optionButtons; private static final int BUTTON_WIDTH = 160; private static final int BUTTON_HEIGHT = 20; @@ -32,11 +34,13 @@ public class ScreenWand extends Screen super(new StringTextComponent("ScreenWand")); this.wand = wand; wandOptions = new WandOptions(wand); + optionButtons = new HashMap<>(); } @Override public void init(Minecraft minecraft, int width, int height) { super.init(minecraft, width, height); + optionButtons.clear(); createButton(0, 0, wandOptions.mode); createButton(0, 1, wandOptions.lock); @@ -47,33 +51,35 @@ public class ScreenWand extends Screen } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - renderBackground(matrixStack); - super.render(matrixStack, mouseX, mouseY, partialTicks); - drawCenteredString(matrixStack, font, wand.getDisplayName(), width/2, height/2 - FIELD_HEIGHT/2 - SPACING_HEIGHT, 16777215); + public void render(int mouseX, int mouseY, float partialTicks) { + renderBackground(); + super.render(mouseX, mouseY, partialTicks); + 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 public boolean charTyped(char character, int code) { - if(character == 'e') closeScreen(); + if(character == 'e') onClose(); return super.charTyped(character, code); } 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(); addButton(button); + optionButtons.put(option, button); } private void clickButton(Button button, IOption option) { option.next(); 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) { - if(isMouseOver(mouseX, mouseY)) { - renderTooltip(matrixStack, new TranslationTextComponent(option.getDescTranslation()), mouseX, mouseY); + private void drawTooltip(int mouseX, int mouseY, IOption option, Button button) { + if(button.isHovered()) { + renderTooltip(new TranslationTextComponent(option.getDescTranslation()).getFormattedText(), mouseX, mouseY); } } @@ -86,6 +92,6 @@ public class ScreenWand extends Screen } 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())); } } 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 2b535a2..004b043 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWand.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWand.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; @@ -33,6 +34,7 @@ public abstract class ItemWand extends Item public ItemWand(String name, Item.Properties properties) { super(properties.group(ItemGroup.TOOLS)); setRegistryName(ConstructionWand.loc(name)); + addPropertyOverride(new ResourceLocation(ConstructionWand.MODID, "wand_mode"), (stack, worldIn, entityIn) -> getWandMode(stack)); } @Override @@ -103,26 +105,26 @@ public abstract class ItemWand extends Item if(Screen.hasShiftDown()) { for(int i=1; i opt = options.allOptions[i]; - lines.add(new TranslationTextComponent(opt.getKeyTranslation()).mergeStyle(TextFormatting.AQUA) - .append(new TranslationTextComponent(opt.getValueTranslation()).mergeStyle(TextFormatting.GRAY)) + lines.add(new TranslationTextComponent(opt.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA) + .appendSibling(new TranslationTextComponent(opt.getValueTranslation()).applyTextStyle(TextFormatting.GRAY)) ); } } else { IOption opt = options.allOptions[0]; - lines.add(new TranslationTextComponent(langTooltip + "blocks", getLimit()).mergeStyle(TextFormatting.GRAY)); - lines.add(new TranslationTextComponent(opt.getKeyTranslation()).mergeStyle(TextFormatting.AQUA) - .append(new TranslationTextComponent(opt.getValueTranslation()).mergeStyle(TextFormatting.WHITE))); - lines.add(new TranslationTextComponent(langTooltip + "shift").mergeStyle(TextFormatting.AQUA)); + lines.add(new TranslationTextComponent(langTooltip + "blocks", getLimit()).applyTextStyle(TextFormatting.GRAY)); + lines.add(new TranslationTextComponent(opt.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA) + .appendSibling(new TranslationTextComponent(opt.getValueTranslation()).applyTextStyle(TextFormatting.WHITE))); + lines.add(new TranslationTextComponent(langTooltip + "shift").applyTextStyle(TextFormatting.AQUA)); } } public static void optionMessage(PlayerEntity player, IOption option) { player.sendStatusMessage( - new TranslationTextComponent(option.getKeyTranslation()).mergeStyle(TextFormatting.AQUA) - .append(new TranslationTextComponent(option.getValueTranslation()).mergeStyle(TextFormatting.WHITE)) - .append(new StringTextComponent(" - ").mergeStyle(TextFormatting.GRAY)) - .append(new TranslationTextComponent(option.getDescTranslation()).mergeStyle(TextFormatting.WHITE)) + new TranslationTextComponent(option.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA) + .appendSibling(new TranslationTextComponent(option.getValueTranslation()).applyTextStyle(TextFormatting.WHITE)) + .appendSibling(new StringTextComponent(" - ").applyTextStyle(TextFormatting.GRAY)) + .appendSibling(new TranslationTextComponent(option.getDescTranslation()).applyTextStyle(TextFormatting.WHITE)) , true); } } diff --git a/src/main/java/thetadev/constructionwand/items/ItemWandBasic.java b/src/main/java/thetadev/constructionwand/items/ItemWandBasic.java index 3186834..ff5d3dd 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWandBasic.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWandBasic.java @@ -2,12 +2,7 @@ package thetadev.constructionwand.items; import net.minecraft.entity.player.PlayerEntity; 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.crafting.Ingredient; -import net.minecraft.tags.ItemTags; -import net.minecraft.util.ResourceLocation; import thetadev.constructionwand.basics.ConfigServer; public class ItemWandBasic extends ItemWand diff --git a/src/main/java/thetadev/constructionwand/items/ItemWandInfinity.java b/src/main/java/thetadev/constructionwand/items/ItemWandInfinity.java index ae9e2aa..666e426 100644 --- a/src/main/java/thetadev/constructionwand/items/ItemWandInfinity.java +++ b/src/main/java/thetadev/constructionwand/items/ItemWandInfinity.java @@ -1,7 +1,6 @@ package thetadev.constructionwand.items; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import thetadev.constructionwand.basics.ConfigServer; @@ -9,7 +8,7 @@ public class ItemWandInfinity extends ItemWand { public ItemWandInfinity(String name) { - super(name, new Properties().maxStackSize(1).isBurnable()); + super(name, new Properties().maxStackSize(1)); } @Override diff --git a/src/main/java/thetadev/constructionwand/items/ModItems.java b/src/main/java/thetadev/constructionwand/items/ModItems.java index f043b7a..e16e5dd 100644 --- a/src/main/java/thetadev/constructionwand/items/ModItems.java +++ b/src/main/java/thetadev/constructionwand/items/ModItems.java @@ -1,14 +1,11 @@ package thetadev.constructionwand.items; import net.minecraft.item.Item; -import net.minecraft.item.ItemModelsProperties; import net.minecraft.item.ItemTier; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.IForgeRegistryEntry; -import thetadev.constructionwand.basics.ConfigServer; import thetadev.constructionwand.ConstructionWand; @Mod.EventBusSubscriber(modid = ConstructionWand.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -26,13 +23,4 @@ public class ModItems { 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) - ); - } - } } diff --git a/src/main/java/thetadev/constructionwand/job/AngelJob.java b/src/main/java/thetadev/constructionwand/job/AngelJob.java index 59d11f3..0a69954 100644 --- a/src/main/java/thetadev/constructionwand/job/AngelJob.java +++ b/src/main/java/thetadev/constructionwand/job/AngelJob.java @@ -6,7 +6,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.ConfigServer; import thetadev.constructionwand.basics.WandUtil; @@ -15,10 +15,10 @@ import thetadev.constructionwand.basics.option.WandOptions; 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); } @@ -28,9 +28,9 @@ public class AngelJob extends WandJob if(!player.isCreative() && !ConfigServer.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/UndoHistory.java b/src/main/java/thetadev/constructionwand/job/UndoHistory.java index dd226ad..39bccbb 100644 --- a/src/main/java/thetadev/constructionwand/job/UndoHistory.java +++ b/src/main/java/thetadev/constructionwand/job/UndoHistory.java @@ -140,7 +140,7 @@ public class UndoHistory // 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/java/thetadev/constructionwand/job/WandItemUseContext.java b/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java index ca32780..dbdc7e7 100644 --- a/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java +++ b/src/main/java/thetadev/constructionwand/job/WandItemUseContext.java @@ -6,8 +6,7 @@ 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 thetadev.constructionwand.basics.WandUtil; +import net.minecraft.util.math.Vec3d; 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)); } - 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 5053465..ad836cf 100644 --- a/src/main/java/thetadev/constructionwand/job/WandJob.java +++ b/src/main/java/thetadev/constructionwand/job/WandJob.java @@ -4,7 +4,7 @@ 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; @@ -233,7 +233,7 @@ public abstract class WandJob // Draw item from pool (returns null if none are left) BlockItem item = itemPool.draw(); if(item == null) return null; - + int count = itemCounts.get(item); if(count == 0) continue; @@ -247,6 +247,9 @@ public abstract class WandJob blockState = Block.getValidBlockForPosition(blockState, world, pos); if(blockState.getBlock() == Blocks.AIR || !blockState.isValidPosition(world, pos)) continue; + // Forbidden Tile Entity? + if(!WandUtil.isTEAllowed(blockState)) continue; + // No entities colliding? VoxelShape shape = blockState.getCollisionShape(world, pos); if(!shape.isEmpty()) { @@ -273,35 +276,35 @@ public abstract class WandJob if(options.direction.get() == WandOptions.DIRECTION.TARGET) { // 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) && placeBlock.hasProperty(property)) { + if(supportingBlock.has(property) && placeBlock.has(property)) { placeBlock = placeBlock.with(property, supportingBlock.get(property)); } } // 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); 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.func_234923_W_(), 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; - } + // Call OnBlockPlaced method + placeBlock.getBlock().onBlockPlacedBy(world, blockPos, placeBlock, player, new ItemStack(placeSnapshot.item)); // Update stats player.addStat(Stats.ITEM_USED.get(placeSnapshot.item)); @@ -342,10 +345,9 @@ public abstract class WandJob } placeSnapshots = placed; - // 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 diff --git a/src/main/java/thetadev/constructionwand/network/PacketUndoBlocks.java b/src/main/java/thetadev/constructionwand/network/PacketUndoBlocks.java index cab030e..5d535f0 100644 --- a/src/main/java/thetadev/constructionwand/network/PacketUndoBlocks.java +++ b/src/main/java/thetadev/constructionwand/network/PacketUndoBlocks.java @@ -6,7 +6,6 @@ import net.minecraftforge.fml.network.NetworkEvent; import thetadev.constructionwand.ConstructionWand; import java.util.HashSet; -import java.util.LinkedList; import java.util.Set; import java.util.function.Supplier; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index cfdd15e..b0a5e69 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,13 +1,13 @@ modLoader="javafml" -loaderVersion="[33,)" 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! @@ -20,12 +20,12 @@ This is my first minecraft mod. May the odds be ever in your favor. [[dependencies.constructionwand]] modId="forge" mandatory=true - versionRange="[33,)" + versionRange="[31,)" ordering="NONE" side="BOTH" [[dependencies.constructionwand]] modId="minecraft" mandatory=true - versionRange="[1.16.2, 1.16.3]" + versionRange="[1.15.2]" 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 6743912..cf3f7d2 100644 --- a/src/main/resources/assets/constructionwand/lang/de_de.json +++ b/src/main/resources/assets/constructionwand/lang/de_de.json @@ -15,13 +15,13 @@ "constructionwand.option.lock": "Beschränkung: ", "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.desc": "Erweitert nach §aoben/unten§f. Baut nicht auf der Ober/Unterseite", - "constructionwand.option.lock.northsouth": "§6North/South", - "constructionwand.option.lock.northsouth.desc": "Erweitert nach §aNorden/Süden§f. Baut nicht an den Seitenflächen", - "constructionwand.option.lock.eastwest": "§6East/West", - "constructionwand.option.lock.eastwest.desc": "Erweitert nach §aOsten/Westen§f. Baut nicht an den Seitenflächen", + "constructionwand.option.lock.vertical.desc": "Baut eine vertikale Säule vor dem Originalblock", + "constructionwand.option.lock.northsouth": "§6Nord/Süd", + "constructionwand.option.lock.northsouth.desc": "Baut eine Reihe in NS-Richtung auf dem Originalblock", + "constructionwand.option.lock.eastwest": "§6Ost/West", + "constructionwand.option.lock.eastwest.desc": "Baut eine Reihe in OW-Richtung auf dem Originalblock", "constructionwand.option.lock.nolock": "§cKeine", "constructionwand.option.lock.nolock.desc": "Erweitert in jede Richtung", @@ -29,7 +29,7 @@ "constructionwand.option.direction.target": "§6Zielblock", "constructionwand.option.direction.target.desc": "Platziert Blöcke mit der selben Ausrichtung wie der Zielblock", "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.yes": "§aJa", @@ -45,11 +45,11 @@ "constructionwand.option.match.any": "§cAlle", "constructionwand.option.match.any.desc": "Erweitert alle Blöcke", - "constructionwand.option.random": "Zufall: ", - "constructionwand.option.random.yes": "§aJa", + "constructionwand.option.random": "Zufallsmodus: ", + "constructionwand.option.random.yes": "§aEin", "constructionwand.option.random.yes.desc": "Platziere zufällige Blöcke aus der Hotbar", - "constructionwand.option.random.no": "§cNein", - "constructionwand.option.random.no.desc": "Platziere Blöcke nicht zufällig", + "constructionwand.option.random.no": "§cAus", + "constructionwand.option.random.no.desc": "Platziere Blöcke normal", "stat.constructionwand.use_wand": "Blöcke mithilfe des Stabs platziert" } \ No newline at end of file diff --git a/src/main/resources/assets/constructionwand/lang/en_us.json b/src/main/resources/assets/constructionwand/lang/en_us.json index 5415b4e..ff6ce4e 100644 --- a/src/main/resources/assets/constructionwand/lang/en_us.json +++ b/src/main/resources/assets/constructionwand/lang/en_us.json @@ -14,14 +14,14 @@ "constructionwand.option.mode.angel.desc": "Place behind blocks and in mid air", "constructionwand.option.lock": "Restriction: ", - "constructionwand.option.lock.horizontal": "§aHorizontal", - "constructionwand.option.lock.horizontal.desc": "Extend §aleft/right§f from the original block. No building on top/bottom face", - "constructionwand.option.lock.vertical": "§aVertical", - "constructionwand.option.lock.vertical.desc": "Extend §aup/down§f from the original block. No building on top/bottom face", + "constructionwand.option.lock.horizontal": "§aLeft/Right", + "constructionwand.option.lock.horizontal.desc": "Build a horizontal column in front of the original block", + "constructionwand.option.lock.vertical": "§aUp/Down", + "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.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.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.desc": "Extend from any side of the original block",