Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61561f6d29 | ||
|
|
7b4a2f6bdd | ||
|
|
586e7df3f6 |
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.14.4-2.18'
|
||||
version = '1.14.4-2.21'
|
||||
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'effortlessbuilding'
|
||||
|
||||
@@ -89,7 +89,7 @@ dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft 'net.minecraftforge:forge:1.14.4-28.1.102'
|
||||
minecraft 'net.minecraftforge:forge:1.14.4-28.2.23'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
|
||||
@@ -46,7 +46,7 @@ public class EffortlessBuilding
|
||||
{
|
||||
public static final String MODID = "effortlessbuilding";
|
||||
public static final String NAME = "Effortless Building";
|
||||
public static final String VERSION = "1.14.4-2.18";
|
||||
public static final String VERSION = "1.14.4-2.21";
|
||||
|
||||
public static EffortlessBuilding instance;
|
||||
|
||||
|
||||
@@ -229,6 +229,31 @@ public class BuildModes {
|
||||
return new Vec3d(x, y, z);
|
||||
}
|
||||
|
||||
//Use this instead of player.getLookVec() in any buildmodes code
|
||||
public static Vec3d getPlayerLookVec(PlayerEntity player){
|
||||
Vec3d lookVec = player.getLookVec();
|
||||
double x = lookVec.x;
|
||||
double y = lookVec.y;
|
||||
double z = lookVec.z;
|
||||
|
||||
//Further calculations (findXBound etc) don't like any component being 0 or 1 (e.g. dividing by 0)
|
||||
//isCriteriaValid below will take up to 2 minutes to raytrace blocks towards infinity if that is the case
|
||||
//So make sure they are close to but never exactly 0 or 1
|
||||
if (Math.abs(x) < 0.0001) x = 0.0001;
|
||||
if (Math.abs(x - 1.0) < 0.0001) x = 0.9999;
|
||||
if (Math.abs(x + 1.0) < 0.0001) x = -0.9999;
|
||||
|
||||
if (Math.abs(y) < 0.0001) y = 0.0001;
|
||||
if (Math.abs(y - 1.0) < 0.0001) y = 0.9999;
|
||||
if (Math.abs(y + 1.0) < 0.0001) y = -0.9999;
|
||||
|
||||
if (Math.abs(z) < 0.0001) z = 0.0001;
|
||||
if (Math.abs(z - 1.0) < 0.0001) z = 0.9999;
|
||||
if (Math.abs(z + 1.0) < 0.0001) z = -0.9999;
|
||||
|
||||
return new Vec3d(x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isCriteriaValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace, Vec3d lineBound, Vec3d planeBound, double distToPlayerSq) {
|
||||
boolean intersects = false;
|
||||
if (!skipRaytrace) {
|
||||
|
||||
@@ -169,7 +169,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
|
||||
//Finds height after floor has been chosen in buildmodes with 3 clicks
|
||||
public static BlockPos findHeight(PlayerEntity player, BlockPos secondPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d look = BuildModes.getPlayerLookVec(player);
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
List<HeightCriteria> criteriaList = new ArrayList<>(3);
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Floor extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
public static BlockPos findFloor(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d look = BuildModes.getPlayerLookVec(player);
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
List<Criteria> criteriaList = new ArrayList<>(3);
|
||||
|
||||
@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
@@ -60,7 +61,7 @@ public class Line extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
public static BlockPos findLine(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d look = BuildModes.getPlayerLookVec(player);
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
List<Criteria> criteriaList = new ArrayList<>(3);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Wall extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
public static BlockPos findWall(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d look = BuildModes.getPlayerLookVec(player);
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
List<Criteria> criteriaList = new ArrayList<>(3);
|
||||
|
||||
@@ -140,8 +140,14 @@ public class RadialMenu extends Screen {
|
||||
final double middleX = width / 2.0;
|
||||
final double middleY = height / 2.0;
|
||||
|
||||
final double mouseXCenter = mouseX - middleX;
|
||||
final double mouseYCenter = -mouseY + middleY;
|
||||
//Fix for high def (retina) displays: use custom mouse coordinates
|
||||
//Borrowed from GameRenderer::updateCameraAndRender
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
int mouseXX = (int)(mc.mouseHelper.getMouseX() * (double)mc.mainWindow.getScaledWidth() / (double)mc.mainWindow.getWidth());
|
||||
int mouseYY = (int)(mc.mouseHelper.getMouseY() * (double)mc.mainWindow.getScaledHeight() / (double)mc.mainWindow.getHeight());
|
||||
|
||||
final double mouseXCenter = mouseXX - middleX;
|
||||
final double mouseYCenter = mouseYY - middleY;
|
||||
double mouseRadians = Math.atan2(mouseYCenter, mouseXCenter);
|
||||
|
||||
final double ringInnerEdge = 30;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.helper;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -57,21 +59,15 @@ public class SurvivalHelper {
|
||||
//Drop existing block
|
||||
dropBlock(world, player, pos);
|
||||
|
||||
//TryPlace sets block with offset, so we only do world.setBlockState now
|
||||
//Remember count of itemstack before tryPlace, and set it back after.
|
||||
//TryPlace reduces stack even in creative so it is not usable here.
|
||||
// int origCount = itemstack.getCount();
|
||||
//TryPlace sets block with offset and reduces itemstack count in creative, so we copy only parts of it
|
||||
// BlockItemUseContext blockItemUseContext = new BlockItemUseContext(world, player, itemstack, pos, facing, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z);
|
||||
// EnumActionResult result = ((ItemBlock) itemstack.getItem()).tryPlace(blockItemUseContext);
|
||||
// itemstack.setCount(origCount);
|
||||
|
||||
//Set our (rotated) blockstate
|
||||
world.setBlockState(pos, blockState, 3);
|
||||
// blockState.onBlockAdded(world, pos, blockState);
|
||||
// block.onBlockPlacedBy(world, pos, blockState, player, itemstack);
|
||||
// world.notifyBlockUpdate(pos, blockState, world.getBlockState(pos), 3);
|
||||
|
||||
// if (result != EnumActionResult.SUCCESS) return false;
|
||||
if (!world.setBlockState(pos, blockState, 3)) return false;
|
||||
BlockItem.setTileEntityNBT(world, player, pos, itemstack); //Actually BlockItem::onBlockPlaced but that is protected
|
||||
block.onBlockPlacedBy(world, pos, blockState, player, itemstack);
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos, itemstack);
|
||||
}
|
||||
|
||||
BlockState afterState = world.getBlockState(pos);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ version="${file.jarVersion}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="Effortless Building" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||
updateJSONURL="http://myurl.me/" #optional
|
||||
#updateJSONURL="example.com" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
displayURL="https://minecraft.curseforge.com/projects/effortless-building" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
|
||||
Reference in New Issue
Block a user