mirror of
https://github.com/Theta-Dev/ConstructionWand.git
synced 2025-04-21 00:50:04 +02:00
Compare commits
62 commits
1.18
...
1.14.4-2.4
Author | SHA1 | Date | |
---|---|---|---|
aeb0e32af4 | |||
0198e468e2 | |||
5b01365abd | |||
f5cb4a414c | |||
356a61816e | |||
f6670138b4 | |||
9f5398e0bc | |||
937742e4fd | |||
bb8c7754d4 | |||
2abea82c76 | |||
b848742f90 | |||
3aee9629df | |||
d4be1e020a | |||
a966a47209 | |||
cb01f789cb | |||
4571faea01 | |||
a29ce8cc22 | |||
35ab23120f | |||
a0be0884f6 | |||
40a4df7a20 | |||
892bff42b5 | |||
896f321cc1 | |||
7b291d514f | |||
e6e282427b | |||
0ea9cfaf46 | |||
3003cdcf18 | |||
0d90de89cf | |||
fe89f27aaa | |||
9aec266dd2 | |||
0ca8f23b69 | |||
e4ca89680d | |||
d87c7f7d1b | |||
c99feca1ee | |||
555d85f879 | |||
87ab64675f | |||
b9353126eb | |||
20b016dd57 | |||
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 |
27 changed files with 159 additions and 230 deletions
12
build.gradle
12
build.gradle
|
@ -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 {
|
||||||
|
@ -137,4 +143,4 @@ publishing {
|
||||||
url "file:///${project.projectDir}/mcmodsrepo"
|
url "file:///${project.projectDir}/mcmodsrepo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ org.gradle.daemon=false
|
||||||
author=thetadev
|
author=thetadev
|
||||||
modid=constructionwand
|
modid=constructionwand
|
||||||
|
|
||||||
mcversion=1.16.5
|
mcversion=1.14.4
|
||||||
forgeversion=36.0.46
|
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=2
|
version_major=2
|
||||||
version_minor=0
|
version_minor=4
|
|
@ -11,7 +11,7 @@
|
||||||
"conditions": {
|
"conditions": {
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"tag": "minecraft:stone_tool_materials"
|
"tag": "forge:cobblestone"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"X": {
|
"X": {
|
||||||
"tag": "minecraft:stone_tool_materials"
|
"tag": "forge:cobblestone"
|
||||||
},
|
},
|
||||||
"#": {
|
"#": {
|
||||||
"tag": "forge:rods/wooden"
|
"tag": "forge:rods/wooden"
|
||||||
|
|
|
@ -82,7 +82,6 @@ public class ConstructionWand
|
||||||
renderBlockPreview = new RenderBlockPreview();
|
renderBlockPreview = new RenderBlockPreview();
|
||||||
MinecraftForge.EVENT_BUS.register(renderBlockPreview);
|
MinecraftForge.EVENT_BUS.register(renderBlockPreview);
|
||||||
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
||||||
ModItems.registerModelProperties();
|
|
||||||
ModItems.registerItemColors();
|
ModItems.registerItemColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,9 @@ import net.minecraft.entity.Entity;
|
||||||
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.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.Property;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.state.properties.SlabType;
|
|
||||||
import net.minecraft.stats.Stats;
|
import net.minecraft.stats.Stats;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.EntityPredicates;
|
import net.minecraft.util.EntityPredicates;
|
||||||
|
@ -21,8 +18,8 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
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.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
@ -62,12 +59,12 @@ public class WandUtil
|
||||||
return new BlockPos(player.getPositionVec());
|
return new BlockPos(player.getPositionVec());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3d entityPositionVec(Entity entity) {
|
public static Vec3d entityPositionVec(Entity entity) {
|
||||||
return new Vector3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight() / 2, entity.getPosZ());
|
return new Vec3d(entity.posX, entity.posY - entity.getYOffset() + entity.getHeight() / 2, entity.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3d blockPosVec(BlockPos pos) {
|
public static Vec3d blockPosVec(BlockPos pos) {
|
||||||
return new Vector3d(pos.getX(), pos.getY(), pos.getZ());
|
return new Vec3d(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> getHotbar(PlayerEntity player) {
|
public static List<ItemStack> getHotbar(PlayerEntity player) {
|
||||||
|
@ -110,17 +107,15 @@ public class WandUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean placeBlock(World world, PlayerEntity player, BlockState block, BlockPos pos, @Nullable BlockItem item) {
|
public static boolean placeBlock(World world, PlayerEntity player, BlockState block, BlockPos pos, @Nullable BlockItem item) {
|
||||||
if(!world.setBlockState(pos, block)) {
|
// Abort if placeEvent is canceled
|
||||||
ConstructionWand.LOGGER.info("Block could not be placed");
|
BlockSnapshot snapshot = new BlockSnapshot(world, pos, block);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove block if placeEvent is canceled
|
|
||||||
BlockSnapshot snapshot = BlockSnapshot.create(world.func_234923_W_(), world, pos);
|
|
||||||
BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, block, player);
|
BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, block, player);
|
||||||
MinecraftForge.EVENT_BUS.post(placeEvent);
|
MinecraftForge.EVENT_BUS.post(placeEvent);
|
||||||
if(placeEvent.isCanceled()) {
|
if(placeEvent.isCanceled()) return false;
|
||||||
world.removeBlock(pos, false);
|
|
||||||
|
// Place the block
|
||||||
|
if(!world.setBlockState(pos, block)) {
|
||||||
|
ConstructionWand.LOGGER.info("Block could not be placed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,17 +203,23 @@ public class WandUtil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if a wand can place a block at a certain position.
|
* Tests if a wand can place a block at a certain position.
|
||||||
* This check is independent from the used block.
|
* This check is independent of the used block.
|
||||||
*/
|
*/
|
||||||
public static boolean isPositionPlaceable(World world, PlayerEntity player, BlockPos pos, boolean replace) {
|
public static boolean isPositionPlaceable(World world, PlayerEntity player, BlockPos pos, boolean replace) {
|
||||||
if(!isPositionModifiable(world,player, pos)) return false;
|
if(!isPositionModifiable(world, player, pos)) return false;
|
||||||
|
|
||||||
// If replace mode is off, target has to be air
|
// If replace mode is off, target has to be air
|
||||||
return replace || world.isAirBlock(pos);
|
if(world.isAirBlock(pos)) return true;
|
||||||
|
|
||||||
|
// Otherwise, check if the block can be replaced by a generic block
|
||||||
|
return replace && world.getBlockState(pos).isReplaceable(
|
||||||
|
new WandItemUseContext(world, player,
|
||||||
|
new BlockRayTraceResult(new Vec3d(0, 0, 0), Direction.DOWN, pos, false),
|
||||||
|
pos, (BlockItem) Items.STONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlockRemovable(World world, PlayerEntity player, BlockPos pos) {
|
public static boolean isBlockRemovable(World world, PlayerEntity player, BlockPos pos) {
|
||||||
if(!isPositionModifiable(world,player, pos)) return false;
|
if(!isPositionModifiable(world, player, pos)) return false;
|
||||||
|
|
||||||
if(!player.isCreative()) {
|
if(!player.isCreative()) {
|
||||||
return !(world.getBlockState(pos).getBlockHardness(world, pos) <= -1) && world.getTileEntity(pos) == null;
|
return !(world.getBlockState(pos).getBlockHardness(world, pos) <= -1) && world.getTileEntity(pos) == null;
|
||||||
|
@ -226,6 +227,10 @@ public class WandUtil
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBlockPermeable(World world, BlockPos pos) {
|
||||||
|
return world.isAirBlock(pos) || world.getBlockState(pos).getCollisionShape(world, pos).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean entitiesCollidingWithBlock(World world, BlockState blockState, BlockPos pos) {
|
public static boolean entitiesCollidingWithBlock(World world, BlockState blockState, BlockPos pos) {
|
||||||
VoxelShape shape = blockState.getCollisionShape(world, pos);
|
VoxelShape shape = blockState.getCollisionShape(world, pos);
|
||||||
if(!shape.isEmpty()) {
|
if(!shape.isEmpty()) {
|
||||||
|
@ -235,7 +240,7 @@ public class WandUtil
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Direction fromVector(Vector3d vector) {
|
public static Direction fromVector(Vec3d vector) {
|
||||||
return Direction.getFacingFromVector(vector.x, vector.y, vector.z);
|
return Direction.getFacingFromVector(vector.x, vector.y, vector.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,8 @@ public class WandUpgrades<T extends IWandUpgrade>
|
||||||
|
|
||||||
for(T item : upgrades) {
|
for(T item : upgrades) {
|
||||||
if(item == dval) continue;
|
if(item == dval) continue;
|
||||||
listnbt.add(StringNBT.valueOf(item.getRegistryName().toString()));
|
listnbt.add(new StringNBT(item.getRegistryName().toString()));
|
||||||
|
|
||||||
}
|
}
|
||||||
tag.put(key, listnbt);
|
tag.put(key, listnbt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class ClientEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isKeyDown(int id) {
|
private static boolean isKeyDown(int id) {
|
||||||
return InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), id);
|
return InputMappings.isKeyDown(Minecraft.getInstance().mainWindow.getHandle(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOptKeyDown() {
|
public static boolean isOptKeyDown() {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package thetadev.constructionwand.client;
|
package thetadev.constructionwand.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
|
||||||
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;
|
||||||
|
@ -12,7 +10,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.items.wand.ItemWand;
|
import thetadev.constructionwand.items.wand.ItemWand;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
BlockRayTraceResult rtr = (BlockRayTraceResult) event.getTarget();
|
BlockRayTraceResult rtr = (BlockRayTraceResult) event.getTarget();
|
||||||
|
@ -52,7 +50,15 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -61,19 +67,33 @@ public class RenderBlockPreview
|
||||||
return rtr1.getPos().equals(rtr2.getPos()) && rtr1.getFace().equals(rtr2.getFace());
|
return rtr1.getPos().equals(rtr2.getPos()) && rtr1.getFace().equals(rtr2.getFace());
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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,12 +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 javax.annotation.Nonnull;
|
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;
|
||||||
|
@ -34,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(@Nonnull 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.cores);
|
createButton(0, 0, wandOptions.cores);
|
||||||
createButton(0, 1, wandOptions.lock);
|
createButton(0, 1, wandOptions.lock);
|
||||||
|
@ -49,33 +51,35 @@ public class ScreenWand extends Screen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(@Nonnull 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package thetadev.constructionwand.data;
|
|
||||||
|
|
||||||
public interface ICustomItemModel
|
|
||||||
{
|
|
||||||
void generateCustomItemModel(ItemModelGenerator generator, String name);
|
|
||||||
}
|
|
|
@ -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
|
||||||
|
@ -22,7 +22,7 @@ public class Inp
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,37 +0,0 @@
|
||||||
package thetadev.constructionwand.data;
|
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraft.item.BlockItem;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
|
||||||
import thetadev.constructionwand.ConstructionWand;
|
|
||||||
import thetadev.constructionwand.items.ModItems;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class ItemModelGenerator extends ItemModelProvider
|
|
||||||
{
|
|
||||||
public ItemModelGenerator(DataGenerator generator, ExistingFileHelper existingFileHelper) {
|
|
||||||
super(generator, ConstructionWand.MODID, existingFileHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void registerModels() {
|
|
||||||
for(Item item : ModItems.ALL_ITEMS) {
|
|
||||||
String name = item.getRegistryName().getPath();
|
|
||||||
|
|
||||||
if(item instanceof ICustomItemModel)
|
|
||||||
((ICustomItemModel) item).generateCustomItemModel(this, name);
|
|
||||||
else if(item instanceof BlockItem)
|
|
||||||
withExistingParent(name, modLoc("block/" + name));
|
|
||||||
else withExistingParent(name, "item/generated").texture("layer0", "item/" + name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return ConstructionWand.MODNAME + " item models";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
package thetadev.constructionwand.data;
|
package thetadev.constructionwand.data;
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
import net.minecraftforge.client.model.generators.ExistingFileHelper;
|
||||||
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.fml.event.lifecycle.GatherDataEvent;
|
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||||
|
@ -17,9 +17,5 @@ public class ModData
|
||||||
if(event.includeServer()) {
|
if(event.includeServer()) {
|
||||||
generator.addProvider(new RecipeGenerator(generator));
|
generator.addProvider(new RecipeGenerator(generator));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.includeClient()) {
|
|
||||||
generator.addProvider(new ItemModelGenerator(generator, fileHelper));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package thetadev.constructionwand.data;
|
||||||
import net.minecraft.data.*;
|
import net.minecraft.data.*;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||||
import net.minecraft.tags.ItemTags;
|
|
||||||
import net.minecraft.util.IItemProvider;
|
import net.minecraft.util.IItemProvider;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
@ -23,7 +22,7 @@ public class RecipeGenerator extends RecipeProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
|
protected void registerRecipes(@Nonnull 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));
|
||||||
|
@ -59,7 +58,7 @@ public class RecipeGenerator extends RecipeProvider
|
||||||
|
|
||||||
private void specialRecipe(Consumer<IFinishedRecipe> consumer, SpecialRecipeSerializer<?> serializer) {
|
private void specialRecipe(Consumer<IFinishedRecipe> consumer, SpecialRecipeSerializer<?> serializer) {
|
||||||
ResourceLocation name = Registry.RECIPE_SERIALIZER.getKey(serializer);
|
ResourceLocation name = Registry.RECIPE_SERIALIZER.getKey(serializer);
|
||||||
CustomRecipeBuilder.customRecipe(serializer).build(consumer, ConstructionWand.loc("dynamic/" + name.getPath()).toString());
|
CustomRecipeBuilder.func_218656_a(serializer).build(consumer, ConstructionWand.loc("dynamic/" + name.getPath()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.color.ItemColors;
|
import net.minecraft.client.renderer.color.ItemColors;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemModelsProperties;
|
|
||||||
import net.minecraft.item.ItemTier;
|
import net.minecraft.item.ItemTier;
|
||||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -74,17 +73,6 @@ public class ModItems
|
||||||
register(r, "wand_upgrade", RecipeWandUpgrade.SERIALIZER);
|
register(r, "wand_upgrade", RecipeWandUpgrade.SERIALIZER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public static void registerModelProperties() {
|
|
||||||
for(Item item : WANDS) {
|
|
||||||
ItemModelsProperties.func_239418_a_(
|
|
||||||
item, ConstructionWand.loc("using_core"),
|
|
||||||
(stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 :
|
|
||||||
new WandOptions(stack).cores.get().getColor() > -1 ? 1 : 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void registerItemColors() {
|
public static void registerItemColors() {
|
||||||
ItemColors colors = Minecraft.getInstance().getItemColors();
|
ItemColors colors = Minecraft.getInstance().getItemColors();
|
||||||
|
|
|
@ -24,8 +24,8 @@ public abstract class ItemCore extends ItemBase implements IWandCore
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void addInformation(@Nonnull ItemStack itemstack, World worldIn, @Nonnull List<ITextComponent> lines, @Nonnull ITooltipFlag extraInfo) {
|
public void addInformation(@Nonnull ItemStack itemstack, World worldIn, @Nonnull List<ITextComponent> lines, @Nonnull ITooltipFlag extraInfo) {
|
||||||
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".option.cores." + getRegistryName().toString() + ".desc")
|
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".option.cores." + getRegistryName().toString() + ".desc")
|
||||||
.mergeStyle(TextFormatting.GRAY));
|
.applyTextStyle(TextFormatting.GRAY));
|
||||||
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".tooltip.core_tip")
|
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".tooltip.core_tip")
|
||||||
.mergeStyle(TextFormatting.AQUA));
|
.applyTextStyle(TextFormatting.AQUA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,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;
|
||||||
|
@ -17,14 +18,11 @@ import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.model.generators.ModelFile;
|
|
||||||
import thetadev.constructionwand.ConstructionWand;
|
import thetadev.constructionwand.ConstructionWand;
|
||||||
import thetadev.constructionwand.api.IWandCore;
|
import thetadev.constructionwand.api.IWandCore;
|
||||||
import thetadev.constructionwand.basics.WandUtil;
|
import thetadev.constructionwand.basics.WandUtil;
|
||||||
import thetadev.constructionwand.basics.option.IOption;
|
import thetadev.constructionwand.basics.option.IOption;
|
||||||
import thetadev.constructionwand.basics.option.WandOptions;
|
import thetadev.constructionwand.basics.option.WandOptions;
|
||||||
import thetadev.constructionwand.data.ICustomItemModel;
|
|
||||||
import thetadev.constructionwand.data.ItemModelGenerator;
|
|
||||||
import thetadev.constructionwand.items.ItemBase;
|
import thetadev.constructionwand.items.ItemBase;
|
||||||
import thetadev.constructionwand.wand.WandJob;
|
import thetadev.constructionwand.wand.WandJob;
|
||||||
|
|
||||||
|
@ -32,10 +30,13 @@ import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
public abstract class ItemWand extends ItemBase
|
||||||
{
|
{
|
||||||
public ItemWand(String name, Properties properties) {
|
public ItemWand(String name, Properties properties) {
|
||||||
super(name, properties);
|
super(name, properties);
|
||||||
|
addPropertyOverride(new ResourceLocation(ConstructionWand.MODID, "using_core"),
|
||||||
|
(stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 :
|
||||||
|
new WandOptions(stack).cores.get().getColor() > -1 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -64,14 +65,14 @@ public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
||||||
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
|
||||||
WandJob job = getWandJob(player, world, BlockRayTraceResult.createMiss(player.getLookVec(),
|
WandJob job = getWandJob(player, world, BlockRayTraceResult.createMiss(player.getLookVec(),
|
||||||
WandUtil.fromVector(player.getLookVec()), WandUtil.playerPos(player)), stack);
|
WandUtil.fromVector(player.getLookVec()), WandUtil.playerPos(player)), 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WandJob getWandJob(PlayerEntity player, World world, @Nullable BlockRayTraceResult rayTraceResult, ItemStack wand) {
|
public static WandJob getWandJob(PlayerEntity player, World world, @Nullable BlockRayTraceResult rayTraceResult, ItemStack wand) {
|
||||||
|
@ -106,13 +107,13 @@ public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
||||||
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))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(!options.cores.getUpgrades().isEmpty()) {
|
if(!options.cores.getUpgrades().isEmpty()) {
|
||||||
lines.add(new StringTextComponent(""));
|
lines.add(new StringTextComponent(""));
|
||||||
lines.add(new TranslationTextComponent(langTooltip + "cores").mergeStyle(TextFormatting.GRAY));
|
lines.add(new TranslationTextComponent(langTooltip + "cores").applyTextStyle(TextFormatting.GRAY));
|
||||||
|
|
||||||
for(IWandCore core : options.cores.getUpgrades()) {
|
for(IWandCore core : options.cores.getUpgrades()) {
|
||||||
lines.add(new TranslationTextComponent(options.cores.getKeyTranslation() + "." + core.getRegistryName().toString()));
|
lines.add(new TranslationTextComponent(options.cores.getKeyTranslation() + "." + core.getRegistryName().toString()));
|
||||||
|
@ -122,33 +123,19 @@ public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
||||||
// Default tooltip: show block limit + active wand core
|
// Default tooltip: show block limit + active wand core
|
||||||
else {
|
else {
|
||||||
IOption<?> opt = options.allOptions[0];
|
IOption<?> opt = options.allOptions[0];
|
||||||
lines.add(new TranslationTextComponent(langTooltip + "blocks", limit).mergeStyle(TextFormatting.GRAY));
|
lines.add(new TranslationTextComponent(langTooltip + "blocks", limit).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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator, String name) {
|
|
||||||
ModelFile wandWithCore = generator.withExistingParent(name + "_core", "item/handheld")
|
|
||||||
.texture("layer0", generator.modLoc("item/" + name))
|
|
||||||
.texture("layer1", generator.modLoc("item/overlay_core"));
|
|
||||||
|
|
||||||
generator.withExistingParent(name, "item/handheld")
|
|
||||||
.texture("layer0", generator.modLoc("item/" + name))
|
|
||||||
.override()
|
|
||||||
.predicate(generator.modLoc("using_core"), 1)
|
|
||||||
.model(wandWithCore).end();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,6 @@ package thetadev.constructionwand.items.wand;
|
||||||
public class ItemWandInfinity extends ItemWand
|
public class ItemWandInfinity extends ItemWand
|
||||||
{
|
{
|
||||||
public ItemWandInfinity(String name, Properties properties) {
|
public ItemWandInfinity(String name, Properties properties) {
|
||||||
super(name, properties.maxStackSize(1).isBurnable());
|
super(name, properties.maxStackSize(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,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 net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import thetadev.constructionwand.basics.WandUtil;
|
import thetadev.constructionwand.basics.WandUtil;
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ public class WandItemUseContext extends BlockItemUseContext
|
||||||
new BlockRayTraceResult(getBlockHitVec(rayTraceResult, pos), rayTraceResult.getFace(), pos, false));
|
new BlockRayTraceResult(getBlockHitVec(rayTraceResult, pos), rayTraceResult.getFace(), pos, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector3d getBlockHitVec(BlockRayTraceResult rayTraceResult, BlockPos pos) {
|
private static Vec3d getBlockHitVec(BlockRayTraceResult rayTraceResult, BlockPos pos) {
|
||||||
Vector3d hitVec = rayTraceResult.getHitVec(); // Absolute coords of hit target
|
Vec3d hitVec = rayTraceResult.getHitVec(); // Absolute coords of hit target
|
||||||
|
|
||||||
Vector3d blockDelta = WandUtil.blockPosVec(rayTraceResult.getPos()).subtract(WandUtil.blockPosVec(pos)); // Vector between start and current block
|
Vec3d blockDelta = WandUtil.blockPosVec(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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.api.IWandAction;
|
import thetadev.constructionwand.api.IWandAction;
|
||||||
import thetadev.constructionwand.api.IWandSupplier;
|
import thetadev.constructionwand.api.IWandSupplier;
|
||||||
|
@ -57,9 +57,9 @@ public class ActionAngel implements IWandAction
|
||||||
|
|
||||||
if(!player.isCreative() && !ConfigServer.ANGEL_FALLING.get() && player.fallDistance > 10) return placeSnapshots;
|
if(!player.isCreative() && !ConfigServer.ANGEL_FALLING.get() && player.fallDistance > 10) return placeSnapshots;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,14 @@ public class ActionDestruction implements IWandAction
|
||||||
HashSet<BlockPos> allCandidates = new HashSet<>();
|
HashSet<BlockPos> allCandidates = new HashSet<>();
|
||||||
|
|
||||||
// Block face the wand was pointed at
|
// Block face the wand was pointed at
|
||||||
Direction breakDirection = rayTraceResult.getFace();
|
Direction breakFace = rayTraceResult.getFace();
|
||||||
// Block the wand was pointed at
|
// Block the wand was pointed at
|
||||||
BlockPos startingPoint = rayTraceResult.getPos();
|
BlockPos startingPoint = rayTraceResult.getPos();
|
||||||
BlockState targetBlock = world.getBlockState(rayTraceResult.getPos());
|
BlockState targetBlock = world.getBlockState(rayTraceResult.getPos());
|
||||||
|
|
||||||
// Is break direction allowed by lock?
|
// Is break direction allowed by lock?
|
||||||
// Tried to break blocks from top/bottom face, so the wand should allow breaking in NS/EW direction
|
// Tried to break blocks from top/bottom face, so the wand should allow breaking in NS/EW direction
|
||||||
if(breakDirection == Direction.UP || breakDirection == Direction.DOWN) {
|
if(breakFace == Direction.UP || breakFace == Direction.DOWN) {
|
||||||
if(options.testLock(WandOptions.LOCK.NORTHSOUTH) || options.testLock(WandOptions.LOCK.EASTWEST))
|
if(options.testLock(WandOptions.LOCK.NORTHSOUTH) || options.testLock(WandOptions.LOCK.EASTWEST))
|
||||||
candidates.add(startingPoint);
|
candidates.add(startingPoint);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,10 @@ public class ActionDestruction implements IWandAction
|
||||||
// Process current candidates, stop when none are avaiable or block limit is reached
|
// Process current candidates, stop when none are avaiable or block limit is reached
|
||||||
while(!candidates.isEmpty() && destroySnapshots.size() < limit) {
|
while(!candidates.isEmpty() && destroySnapshots.size() < limit) {
|
||||||
BlockPos currentCandidate = candidates.removeFirst();
|
BlockPos currentCandidate = candidates.removeFirst();
|
||||||
|
|
||||||
|
// Only break blocks facing the player, with no collidable blocks in between
|
||||||
|
if(!WandUtil.isBlockPermeable(world, currentCandidate.offset(breakFace))) continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BlockState candidateBlock = world.getBlockState(currentCandidate);
|
BlockState candidateBlock = world.getBlockState(currentCandidate);
|
||||||
|
|
||||||
|
@ -67,7 +71,7 @@ public class ActionDestruction implements IWandAction
|
||||||
if(snapshot == null) continue;
|
if(snapshot == null) continue;
|
||||||
destroySnapshots.add(snapshot);
|
destroySnapshots.add(snapshot);
|
||||||
|
|
||||||
switch(breakDirection) {
|
switch(breakFace) {
|
||||||
case DOWN:
|
case DOWN:
|
||||||
case UP:
|
case UP:
|
||||||
if(options.testLock(WandOptions.LOCK.NORTHSOUTH)) {
|
if(options.testLock(WandOptions.LOCK.NORTHSOUTH)) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
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;
|
||||||
|
@ -51,7 +52,7 @@ public class SupplierInventory implements IWandSupplier
|
||||||
addBlockItem((BlockItem) offhandStack.getItem());
|
addBlockItem((BlockItem) offhandStack.getItem());
|
||||||
}
|
}
|
||||||
// Otherwise use target block
|
// Otherwise use target block
|
||||||
else {
|
else if(target != null && target != Items.AIR) {
|
||||||
addBlockItem(target);
|
addBlockItem(target);
|
||||||
|
|
||||||
// Add replacement items
|
// Add replacement items
|
||||||
|
|
|
@ -2,7 +2,6 @@ package thetadev.constructionwand.wand.undo;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.fluid.Fluids;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
@ -59,8 +58,8 @@ public class DestroySnapshot implements ISnapshot
|
||||||
// Ignore blocks and entities when in creative
|
// Ignore blocks and entities when in creative
|
||||||
if(player.isCreative()) return true;
|
if(player.isCreative()) return true;
|
||||||
|
|
||||||
// Is block empty or fluid?
|
// Is block empty?
|
||||||
if(!world.isAirBlock(pos) && !world.getBlockState(pos).isReplaceable(Fluids.EMPTY)) return false;
|
if(!world.isAirBlock(pos)) return false;
|
||||||
|
|
||||||
return !WandUtil.entitiesCollidingWithBlock(world, block, pos);
|
return !WandUtil.entitiesCollidingWithBlock(world, block, pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,8 @@ public class PlaceSnapshot implements ISnapshot
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Nullable
|
@Nullable
|
||||||
private static BlockState getPlaceBlockstate(World world, PlayerEntity player, BlockRayTraceResult rayTraceResult,
|
private static BlockState getPlaceBlockstate(World world, PlayerEntity player, BlockRayTraceResult rayTraceResult,
|
||||||
BlockPos pos, BlockItem item,
|
BlockPos pos, BlockItem item,
|
||||||
@Nullable BlockState supportingBlock, boolean targetMode) {
|
@Nullable BlockState supportingBlock, boolean targetMode) {
|
||||||
// Is block at pos replaceable?
|
// Is block at pos replaceable?
|
||||||
BlockItemUseContext ctx = new WandItemUseContext(world, player, rayTraceResult, pos, item);
|
BlockItemUseContext ctx = new WandItemUseContext(world, player, rayTraceResult, pos, item);
|
||||||
if(!ctx.canPlace()) return null;
|
if(!ctx.canPlace()) return null;
|
||||||
|
@ -119,13 +119,13 @@ public class PlaceSnapshot implements ISnapshot
|
||||||
for(Property property : new Property[]{
|
for(Property property : new Property[]{
|
||||||
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) && blockState.hasProperty(property)) {
|
if(supportingBlock.has(property) && blockState.has(property)) {
|
||||||
blockState = blockState.with(property, supportingBlock.get(property));
|
blockState = blockState.with(property, supportingBlock.get(property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dont dupe double slabs
|
// Dont dupe double slabs
|
||||||
if(supportingBlock.hasProperty(BlockStateProperties.SLAB_TYPE) && blockState.hasProperty(BlockStateProperties.SLAB_TYPE)) {
|
if(supportingBlock.has(BlockStateProperties.SLAB_TYPE) && blockState.has(BlockStateProperties.SLAB_TYPE)) {
|
||||||
SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE);
|
SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE);
|
||||||
if(slabType != SlabType.DOUBLE) blockState = blockState.with(BlockStateProperties.SLAB_TYPE, slabType);
|
if(slabType != SlabType.DOUBLE) blockState = blockState.with(BlockStateProperties.SLAB_TYPE, slabType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
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}"
|
||||||
|
@ -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.5]"
|
versionRange="[1.14.4]"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
|
|
Loading…
Add table
Reference in a new issue