mirror of
https://github.com/Theta-Dev/ConstructionWand.git
synced 2025-04-21 00:50:04 +02:00
Compare commits
28 commits
Author | SHA1 | Date | |
---|---|---|---|
c99feca1ee | |||
555d85f879 | |||
b9353126eb | |||
95d3c504ba | |||
5caa2b6fcc | |||
4876683b07 | |||
64f947e535 | |||
cd99733803 | |||
1186043bf3 | |||
c4e73e7a0a | |||
97a037611c | |||
fa1587f269 | |||
e3918bc9bb | |||
89fbd5313b | |||
e3d6f161a2 | |||
2df50e381d | |||
c141eddd2d | |||
fc8bb4b6ef | |||
6149dc4114 | |||
dfbdb10a80 | |||
bab43266a6 | |||
ce9673ee87 | |||
37dd871056 | |||
493861f8c9 | |||
d3eaa22505 | |||
36fa9efb32 | |||
c96feedb91 | |||
3f067cec30 |
21 changed files with 143 additions and 162 deletions
|
@ -37,7 +37,7 @@ Every wand has two additional options that can be changed using keys. (Standard:
|
|||
|
||||

|
||||
|
||||
**Fluid lock:** Enables/disables the replacement of fluid blocks (both source + flowing).
|
||||
**Replacement:** Enables/disables the replacement of replaceable blocks (snow, tallgrass and fluids).
|
||||
|
||||
## Additional features
|
||||
- If you have shulker boxes in your inventory filled with blocks, the wand can pull them out and place them
|
||||
|
|
25
build.gradle
25
build.gradle
|
@ -13,15 +13,25 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.16.2-1.2'
|
||||
version = '1.14-1.2'
|
||||
group = 'thetadev.constructionwand' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'constructionwand'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20200723-1.16.1'
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||
// stable_# Stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: 'snapshot', version: '20190719-1.14.3'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file("run/client").canonicalPath
|
||||
|
@ -92,12 +102,13 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.16.2-33.0.21'
|
||||
//runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16-39")
|
||||
//runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.16.1-3.0")
|
||||
minecraft 'net.minecraftforge:forge:1.14.4-28.2.23'
|
||||
|
||||
compileOnly fg.deobf("vazkii.botania:Botania:1.16-398:api")
|
||||
//runtimeOnly fg.deobf("vazkii.botania:Botania:1.16-398")
|
||||
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.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 {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"tag": "minecraft:stone_tool_materials"
|
||||
"tag": "forge:cobblestone"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"X": {
|
||||
"tag": "minecraft:stone_tool_materials"
|
||||
"tag": "forge:cobblestone"
|
||||
},
|
||||
"#": {
|
||||
"tag": "forge:rods/wooden"
|
||||
|
|
|
@ -18,7 +18,6 @@ import thetadev.constructionwand.client.KeyEvents;
|
|||
import thetadev.constructionwand.client.RenderBlockPreview;
|
||||
import thetadev.constructionwand.containers.ContainerManager;
|
||||
import thetadev.constructionwand.containers.ContainerRegistrar;
|
||||
import thetadev.constructionwand.items.ModItems;
|
||||
import thetadev.constructionwand.job.JobHistory;
|
||||
import thetadev.constructionwand.network.PacketQueryUndo;
|
||||
import thetadev.constructionwand.network.PacketUndoBlocks;
|
||||
|
@ -76,6 +75,5 @@ public class ConstructionWand
|
|||
renderBlockPreview = new RenderBlockPreview();
|
||||
MinecraftForge.EVENT_BUS.register(renderBlockPreview);
|
||||
MinecraftForge.EVENT_BUS.register(new KeyEvents());
|
||||
ModItems.registerModelProperties();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,20 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import thetadev.constructionwand.basics.options.EnumMode;
|
||||
import thetadev.constructionwand.basics.options.IEnumOption;
|
||||
import thetadev.constructionwand.basics.options.WandOptions;
|
||||
import thetadev.constructionwand.items.ItemWand;
|
||||
import thetadev.constructionwand.job.ConstructionJob;
|
||||
import thetadev.constructionwand.job.TransductionJob;
|
||||
import thetadev.constructionwand.job.WandJob;
|
||||
|
||||
public class WandUtil
|
||||
{
|
||||
|
@ -30,15 +40,7 @@ public class WandUtil
|
|||
return null;
|
||||
}
|
||||
|
||||
public static BlockPos playerPos(PlayerEntity player) {
|
||||
return new BlockPos(player.getPositionVec());
|
||||
}
|
||||
|
||||
public static Vector3d entityPositionVec(Entity entity) {
|
||||
return new Vector3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight()/2, entity.getPosZ());
|
||||
}
|
||||
|
||||
public static Vector3d blockPosVec(BlockPos pos) {
|
||||
return new Vector3d(pos.getX(), pos.getY(), pos.getZ());
|
||||
public static Vec3d entityPositionVec(Entity entity) {
|
||||
return new Vec3d(entity.posX, entity.posY - entity.getYOffset() + entity.getHeight()/2, entity.posZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,11 @@ public class KeyEvents
|
|||
private final String langPrefix = ConstructionWand.MODID + ".key.";
|
||||
private final String langCategory = langPrefix + "category";
|
||||
|
||||
public final KeyBinding[] keys = {
|
||||
new KeyBinding(langPrefix+"direction", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_N, 0), langCategory),
|
||||
new KeyBinding(langPrefix+"replace", KeyConflictContext.IN_GAME, KeyModifier.SHIFT, InputMappings.getInputByCode(GLFW.GLFW_KEY_N, 0), langCategory)
|
||||
public final KeyBinding WAND_KEY = new KeyBinding(langPrefix+"wand", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_N, 0), langCategory);
|
||||
|
||||
public static final KeyModifier[] keyModifiers = {
|
||||
KeyModifier.NONE,
|
||||
KeyModifier.SHIFT
|
||||
};
|
||||
|
||||
public static final IEnumOption[] keyOptions = {
|
||||
|
@ -42,8 +44,8 @@ public class KeyEvents
|
|||
private boolean ctrlPressed;
|
||||
|
||||
public KeyEvents() {
|
||||
for(KeyBinding key : keys) ClientRegistry.registerKeyBinding(key);
|
||||
ctrlPressed = false;
|
||||
ClientRegistry.registerKeyBinding(WAND_KEY);
|
||||
ctrlPressed = false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -52,10 +54,12 @@ public class KeyEvents
|
|||
if(player == null) return;
|
||||
if(WandUtil.holdingWand(player) == null) return;
|
||||
|
||||
for(int i=0; i<keyOptions.length; i++) {
|
||||
if(keys[i].isPressed()) {
|
||||
PacketWandOption packet = new PacketWandOption(keyOptions[i], true);
|
||||
ConstructionWand.instance.HANDLER.sendToServer(packet);
|
||||
if(WAND_KEY.isPressed()) {
|
||||
for(int i=0; i<keyOptions.length; i++) {
|
||||
if(keyModifiers[i].isActive(null)) {
|
||||
PacketWandOption packet = new PacketWandOption(keyOptions[i], true);
|
||||
ConstructionWand.instance.HANDLER.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
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.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
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.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.client.event.DrawHighlightEvent;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import thetadev.constructionwand.basics.WandUtil;
|
||||
import thetadev.constructionwand.job.WandJob;
|
||||
|
@ -26,7 +24,7 @@ public class RenderBlockPreview
|
|||
public LinkedList<BlockPos> undoBlocks;
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderBlockHighlight(DrawHighlightEvent event)
|
||||
public void renderBlockHighlight(DrawBlockHighlightEvent event)
|
||||
{
|
||||
if(event.getTarget().getType() != RayTraceResult.Type.BLOCK) return;
|
||||
|
||||
|
@ -54,24 +52,48 @@ public class RenderBlockPreview
|
|||
|
||||
if(blocks == null || blocks.isEmpty()) return;
|
||||
|
||||
renderBlockList(blocks, event.getMatrix(), event.getBuffers(), colorR, colorG, colorB);
|
||||
for(BlockPos block : blocks) {
|
||||
|
||||
double partialTicks = event.getPartialTicks();
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double d1 = player.lastTickPosY + player.getEyeHeight() + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(block).offset(-d0, -d1, -d2);
|
||||
//WorldRenderer.drawSelectionBoundingBox(aabb, colorR, colorG, colorB, 0.4F);
|
||||
drawBoundingBox(aabb, colorR, colorG, colorB, 0.4F);
|
||||
}
|
||||
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
private void renderBlockList(LinkedList<BlockPos> blocks, MatrixStack ms, IRenderTypeBuffer buffer, float red, float green, float blue) {
|
||||
double renderPosX = Minecraft.getInstance().getRenderManager().info.getProjectedView().getX();
|
||||
double renderPosY = Minecraft.getInstance().getRenderManager().info.getProjectedView().getY();
|
||||
double renderPosZ = Minecraft.getInstance().getRenderManager().info.getProjectedView().getZ();
|
||||
private static void drawBoundingBox(AxisAlignedBB box, float red, float green, float blue, float alpha) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
|
||||
|
||||
ms.push();
|
||||
ms.translate(-renderPosX, -renderPosY, -renderPosZ);
|
||||
//Base
|
||||
buffer.pos(box.minX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.maxX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.maxX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.minX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.minX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
//Side1
|
||||
buffer.pos(box.minX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.minX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.minX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
//Side2
|
||||
buffer.pos(box.minX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.maxX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.maxX, box.minY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
//Side3
|
||||
buffer.pos(box.maxX, box.maxY, box.maxZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.maxX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.maxX, box.minY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
//Side4
|
||||
buffer.pos(box.maxX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
buffer.pos(box.minX, box.maxY, box.minZ).color(red, green, blue, alpha).endVertex();
|
||||
|
||||
for(BlockPos block : blocks) {
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(block);
|
||||
IVertexBuilder lineBuilder = buffer.getBuffer(RenderTypes.TRANSLUCENT_LINES);
|
||||
WorldRenderer.drawBoundingBox(ms, lineBuilder, aabb, red, green, blue, 0.4F);
|
||||
}
|
||||
ms.pop();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<Item> in) {
|
||||
return new Inp(in.getName().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build());
|
||||
public static Inp fromTag(Tag<Item> in) {
|
||||
return new Inp(in.getId().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build());
|
||||
}
|
||||
}
|
|
@ -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<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_DIAMOND, Inp.fromTag(Tags.Items.GEMS_DIAMOND));
|
||||
wandRecipe(consumer, ModItems.WAND_INFINITY, Inp.fromTag(Tags.Items.NETHER_STARS));
|
||||
|
|
|
@ -43,6 +43,8 @@ public abstract class ItemWand extends Item
|
|||
super(properties.group(ItemGroup.TOOLS));
|
||||
this.maxBlocks = maxBlocks;
|
||||
this.angelDistance = angelDistance;
|
||||
addPropertyOverride(new ResourceLocation(ConstructionWand.MODID, "wand_mode"),
|
||||
(stack, worldIn, entityIn) -> getWandMode(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +74,7 @@ public abstract class ItemWand extends Item
|
|||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
|
||||
if(world.isRemote) return ActionResult.resultFail(stack);
|
||||
if(world.isRemote) return new ActionResult<>(ActionResultType.FAIL, stack);
|
||||
|
||||
if(player.isSneaking()) {
|
||||
// SHIFT + Right click: Change wand mode
|
||||
|
@ -85,13 +87,13 @@ public abstract class ItemWand extends Item
|
|||
optionMessage(player, opt);
|
||||
|
||||
player.inventory.markDirty();
|
||||
return ActionResult.resultSuccess(stack);
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, stack);
|
||||
}
|
||||
else {
|
||||
// Right click: Place angel block
|
||||
//ConstructionWand.LOGGER.debug("Place angel block");
|
||||
WandJob job = new AngelJob(player, world, stack);
|
||||
return job.doIt() ? ActionResult.resultSuccess(stack) : ActionResult.resultFail(stack);
|
||||
return new ActionResult<>(job.doIt() ? ActionResultType.SUCCESS : ActionResultType.FAIL, stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,17 +127,17 @@ public abstract class ItemWand extends Item
|
|||
if(Screen.hasShiftDown()) {
|
||||
for(int i=1; i<WandOptions.options.length; i++) {
|
||||
IEnumOption opt = WandOptions.options[i];
|
||||
lines.add(new TranslationTextComponent(langPrefix + opt.getOptionKey()).mergeStyle(TextFormatting.AQUA)
|
||||
.append(new TranslationTextComponent(langPrefix + options.getOption(opt).getTranslationKey()).mergeStyle(TextFormatting.GRAY))
|
||||
lines.add(new TranslationTextComponent(langPrefix + opt.getOptionKey()).applyTextStyle(TextFormatting.AQUA)
|
||||
.appendSibling(new TranslationTextComponent(langPrefix + options.getOption(opt).getTranslationKey()).applyTextStyle(TextFormatting.GRAY))
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
IEnumOption opt = WandOptions.options[0];
|
||||
lines.add(new TranslationTextComponent(langTooltip + "blocks", wand.maxBlocks).mergeStyle(TextFormatting.GRAY));
|
||||
lines.add(new TranslationTextComponent(langPrefix+opt.getOptionKey()).mergeStyle(TextFormatting.AQUA)
|
||||
.append(new TranslationTextComponent(langPrefix+options.getOption(opt).getTranslationKey()).mergeStyle(TextFormatting.WHITE)));
|
||||
lines.add(new TranslationTextComponent(langTooltip + "shift").mergeStyle(TextFormatting.AQUA));
|
||||
lines.add(new TranslationTextComponent(langTooltip + "blocks", wand.maxBlocks).applyTextStyle(TextFormatting.GRAY));
|
||||
lines.add(new TranslationTextComponent(langPrefix+opt.getOptionKey()).applyTextStyle(TextFormatting.AQUA)
|
||||
.appendSibling(new TranslationTextComponent(langPrefix+options.getOption(opt).getTranslationKey()).applyTextStyle(TextFormatting.WHITE)));
|
||||
lines.add(new TranslationTextComponent(langTooltip + "shift").applyTextStyle(TextFormatting.AQUA));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,10 +145,10 @@ public abstract class ItemWand extends Item
|
|||
String langPrefix = ConstructionWand.MODID + ".option.";
|
||||
|
||||
player.sendStatusMessage(
|
||||
new TranslationTextComponent(langPrefix+option.getOptionKey()).mergeStyle(TextFormatting.AQUA)
|
||||
.append(new TranslationTextComponent(langPrefix+option.getTranslationKey()).mergeStyle(TextFormatting.WHITE))
|
||||
.append(new StringTextComponent(" - ").mergeStyle(TextFormatting.GRAY))
|
||||
.append(new TranslationTextComponent(langPrefix+option.getTranslationKey()+".desc").mergeStyle(TextFormatting.WHITE))
|
||||
new TranslationTextComponent(langPrefix+option.getOptionKey()).applyTextStyle(TextFormatting.AQUA)
|
||||
.appendSibling(new TranslationTextComponent(langPrefix+option.getTranslationKey()).applyTextStyle(TextFormatting.WHITE))
|
||||
.appendSibling(new StringTextComponent(" - ").applyTextStyle(TextFormatting.GRAY))
|
||||
.appendSibling(new TranslationTextComponent(langPrefix+option.getTranslationKey()+".desc").applyTextStyle(TextFormatting.WHITE))
|
||||
, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ 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;
|
||||
|
||||
public class ItemWandBasic extends ItemWand
|
||||
{
|
||||
|
|
|
@ -4,15 +4,13 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import thetadev.constructionwand.basics.ConfigHandler;
|
||||
|
||||
public class ItemWandInfinity extends ItemWand
|
||||
{
|
||||
public ItemWandInfinity(int maxBlocks, int angelDistance)
|
||||
{
|
||||
//func_234689_a_(): Dont burn like Netherite
|
||||
super(new Item.Properties().maxStackSize(1).isBurnable(), maxBlocks, angelDistance);
|
||||
super(new Item.Properties().maxStackSize(1), maxBlocks, angelDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
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;
|
||||
|
@ -19,8 +18,6 @@ public class ModItems
|
|||
public static final Item WAND_DIAMOND = new ItemWandBasic(ItemTier.DIAMOND, ConfigHandler.DURABILITY_DIAMOND.get(), ConfigHandler.LIMIT_DIAMOND.get(), ConfigHandler.ANGEL_DIAMOND.get());
|
||||
public static final Item WAND_INFINITY = new ItemWandInfinity(ConfigHandler.LIMIT_INFINITY.get(), ConfigHandler.ANGEL_INFINITY.get());
|
||||
|
||||
public static final Item[] WANDS = {WAND_STONE, WAND_IRON, WAND_DIAMOND, WAND_INFINITY};
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
|
@ -40,13 +37,4 @@ public class ModItems
|
|||
entry.setRegistryName(registryName);
|
||||
return entry;
|
||||
}
|
||||
|
||||
public static void registerModelProperties() {
|
||||
for(Item item : WANDS) {
|
||||
ItemModelsProperties.func_239418_a_(
|
||||
item, new ResourceLocation(ConstructionWand.MODID, "wand_mode"),
|
||||
(stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 : ItemWand.getWandMode(stack)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import thetadev.constructionwand.basics.ConfigHandler;
|
||||
import thetadev.constructionwand.basics.WandUtil;
|
||||
|
@ -14,10 +14,10 @@ import thetadev.constructionwand.basics.options.EnumMode;
|
|||
public class AngelJob extends WandJob
|
||||
{
|
||||
public AngelJob(PlayerEntity player, World world, ItemStack wand) {
|
||||
super(player, world, new BlockRayTraceResult(player.getLookVec(), fromVector(player.getLookVec()), WandUtil.playerPos(player), false), wand);
|
||||
super(player, world, new BlockRayTraceResult(player.getLookVec(), fromVector(player.getLookVec()), player.getPosition(), false), wand);
|
||||
}
|
||||
|
||||
private static Direction fromVector(Vector3d vector) {
|
||||
private static Direction fromVector(Vec3d vector) {
|
||||
return Direction.getFacingFromVector(vector.x, vector.y, vector.z);
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,9 @@ public class AngelJob extends WandJob
|
|||
|
||||
if(!player.isCreative() && !ConfigHandler.ANGEL_FALLING.get() && player.fallDistance > 10) return;
|
||||
|
||||
Vector3d playerVec = WandUtil.entityPositionVec(player);
|
||||
Vector3d lookVec = player.getLookVec().mul(2, 2, 2);
|
||||
Vector3d placeVec = playerVec.add(lookVec);
|
||||
Vec3d playerVec = WandUtil.entityPositionVec(player);
|
||||
Vec3d lookVec = player.getLookVec().mul(2, 2, 2);
|
||||
Vec3d placeVec = playerVec.add(lookVec);
|
||||
|
||||
BlockPos currentPos = new BlockPos(placeVec);
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package thetadev.constructionwand.job;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import thetadev.constructionwand.basics.WandUtil;
|
||||
|
||||
public class WandItemUseContext extends BlockItemUseContext
|
||||
|
@ -14,10 +16,9 @@ public class WandItemUseContext extends BlockItemUseContext
|
|||
super(job.world, job.player, Hand.MAIN_HAND, new ItemStack(job.placeItem), new BlockRayTraceResult(getBlockHitVec(job, pos), job.rayTraceResult.getFace(), pos, false));
|
||||
}
|
||||
|
||||
private static Vector3d getBlockHitVec(WandJob job, BlockPos pos) {
|
||||
Vector3d hitVec = job.rayTraceResult.getHitVec(); // Absolute coords of hit target
|
||||
|
||||
Vector3d blockDelta = WandUtil.blockPosVec(job.rayTraceResult.getPos()).subtract(WandUtil.blockPosVec(pos)); // Vector between start and current block
|
||||
private static Vec3d getBlockHitVec(WandJob job, BlockPos pos) {
|
||||
Vec3d hitVec = job.rayTraceResult.getHitVec(); // Absolute coords of hit target
|
||||
Vec3d blockDelta = new Vec3d(job.rayTraceResult.getPos()).subtract(new Vec3d(pos)); // Vector between start and current block
|
||||
|
||||
return blockDelta.add(hitVec); // Absolute coords of current block hit target
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -221,39 +221,33 @@ public abstract class WandJob
|
|||
|
||||
if(targetDirection) {
|
||||
// Block properties to be copied (alignment/rotation properties)
|
||||
for(Property property : new Property[] {
|
||||
for(IProperty property : new IProperty[] {
|
||||
BlockStateProperties.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP,
|
||||
BlockStateProperties.ROTATION_0_15, BlockStateProperties.AXIS, BlockStateProperties.HALF, BlockStateProperties.STAIRS_SHAPE})
|
||||
{
|
||||
if(supportingBlock.hasProperty(property)) {
|
||||
if(supportingBlock.has(property)) {
|
||||
placeBlock = placeBlock.with(property, supportingBlock.get(property));
|
||||
}
|
||||
}
|
||||
|
||||
// Dont dupe double slabs
|
||||
if(supportingBlock.hasProperty(BlockStateProperties.SLAB_TYPE)) {
|
||||
if(supportingBlock.has(BlockStateProperties.SLAB_TYPE)) {
|
||||
SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE);
|
||||
if(slabType != SlabType.DOUBLE) placeBlock = placeBlock.with(BlockStateProperties.SLAB_TYPE, slabType);
|
||||
}
|
||||
}
|
||||
// Abort if placeEvent is canceled
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world, blockPos, placeBlock);
|
||||
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;
|
||||
}
|
||||
|
||||
// Update neighbor block states
|
||||
world.notifyNeighborsOfStateChange(blockPos, placeBlock.getBlock());
|
||||
world.notifyNeighbors(blockPos, placeBlock.getBlock());
|
||||
|
||||
// Update stats
|
||||
player.addStat(Stats.ITEM_USED.get(placeItem));
|
||||
|
@ -287,7 +281,7 @@ public abstract class WandJob
|
|||
// Play place sound
|
||||
if(!placeSnapshots.isEmpty()) {
|
||||
SoundType sound = placeSnapshots.getFirst().block.getSoundType();
|
||||
world.playSound(null, WandUtil.playerPos(player), sound.getPlaceSound(), SoundCategory.BLOCKS, sound.volume, sound.pitch);
|
||||
world.playSound(null, player.getPosition(), sound.getPlaceSound(), SoundCategory.BLOCKS, sound.volume, sound.pitch);
|
||||
}
|
||||
|
||||
// Add to job history for undo
|
||||
|
@ -323,7 +317,7 @@ public abstract class WandJob
|
|||
|
||||
// Play teleport sound
|
||||
SoundEvent sound = SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
|
||||
world.playSound(null, WandUtil.playerPos(player), sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
world.playSound(null, player.getPosition(), sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
modLoader="javafml"
|
||||
loaderVersion="[33,)"
|
||||
license="MIT License"
|
||||
loaderVersion="[28,)"
|
||||
[[mods]]
|
||||
modId="constructionwand"
|
||||
version="${file.jarVersion}"
|
||||
displayName="Construction Wand"
|
||||
displayURL="https://github.com/Theta-Dev/ConstructionWand" #optional
|
||||
logoFile="logo.png" #optional
|
||||
authors="ThetaDev" #optional
|
||||
logoFile="logo.png"
|
||||
authors="ThetaDev"
|
||||
description='''
|
||||
Construction Wands make building easier!
|
||||
|
||||
|
@ -20,12 +19,12 @@ This is my first minecraft mod. May the odds be ever in your favor.
|
|||
[[dependencies.constructionwand]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[33,)"
|
||||
versionRange="[28,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
[[dependencies.constructionwand]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.16.2]"
|
||||
versionRange="[1.14.4]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"item.constructionwand.infinity_wand": "Stab der Unendlichkeit",
|
||||
|
||||
"constructionwand.key.category": "Construction Wand",
|
||||
"constructionwand.key.wand": "Ausrichtung (+SHIFT: Ersetzungsmodus)",
|
||||
"constructionwand.key.direction": "Ausrichtung",
|
||||
"constructionwand.key.replace": "Ersetzungsmodus",
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"item.constructionwand.infinity_wand": "Infinity Wand",
|
||||
|
||||
"constructionwand.key.category": "Construction Wand",
|
||||
"constructionwand.key.wand": "Place direction (+SHIFT: Replacement mode)",
|
||||
"constructionwand.key.direction": "Place direction",
|
||||
"constructionwand.key.replace": "Replacement mode",
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue