Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.14' into 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
kindlich committed Jan 5, 2020
2 parents 57cc981 + 5a72b2d commit 3313cae
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 56 deletions.
Expand Up @@ -14,7 +14,7 @@
import com.blamejared.crafttweaker.impl.potion.MCEffect;
import com.blamejared.crafttweaker.impl.potion.MCPotion;
import com.blamejared.crafttweaker.impl.tag.MCTag;
import com.blamejared.crafttweaker.impl.util.CTDirectionAxis;
import com.blamejared.crafttweaker.impl.util.MCDirectionAxis;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityClassification;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -216,7 +216,7 @@ public static Collection<String> getEntityClassificationDump() {
}

@BracketResolver("directionaxis")
public static CTDirectionAxis getDirectionAxis(String tokens) {
public static MCDirectionAxis getDirectionAxis(String tokens) {
if(!tokens.toLowerCase(Locale.ENGLISH).equals(tokens))
CraftTweakerAPI.logWarning("DirectionAxis BEP <directionaxis:%s> does not seem to be lower-cased!", tokens);

Expand All @@ -227,7 +227,7 @@ public static CTDirectionAxis getDirectionAxis(String tokens) {
if(Direction.Axis.byName(split[0]) != null) {
throw new IllegalArgumentException("Could not get axis with name: <directionaxis:" + tokens + ">! Axis does not appear to exist!");
}
return CTDirectionAxis.getAxis(Direction.Axis.byName(split[0]));
return MCDirectionAxis.getAxis(Direction.Axis.byName(split[0]));
}

@BracketDumper("directionaxis")
Expand Down
Expand Up @@ -142,7 +142,7 @@ public ItemStack getCraftingResult(CraftingInventory inv) {

@Override
public boolean canFit(int width, int height) {
return this.height >= height && this.width >= width;
return width >= this.width && height >= this.height;
}

@Override
Expand Down
Expand Up @@ -73,7 +73,7 @@ public IRecipeManager.RecipeFunctionArray getFunction() {

@Override
public boolean canFit(int width, int height) {
return ingredients.length >= width * height;
return width * height >= this.ingredients.length;
}

@Override
Expand Down
Expand Up @@ -15,16 +15,15 @@
@ZenCodeType.Name("crafttweaker.api.util.BlockPos")
@Document("vanilla/util/BlockPos")
@ZenWrapper(wrappedClass = "net.minecraft.util.math.BlockPos", conversionMethodFormat = "%s.getInternal()", displayStringFormat = "%s.getInternal.toString()")
public class CTBlockPos {

public class MCBlockPos {
private BlockPos internal;

public CTBlockPos(BlockPos internal) {
public MCBlockPos(BlockPos internal) {
this.internal = internal;
}

@ZenCodeType.Constructor
public CTBlockPos(int x, int y, int z) {
public MCBlockPos(int x, int y, int z) {
this.internal = new BlockPos(x, y, z);
}

Expand All @@ -47,8 +46,8 @@ public long toLong() {
* @docParam z -25.2
*/
@ZenCodeType.Method
public CTBlockPos add(double x, double y, double z) {
return x == 0.0D && y == 0.0D && z == 0.0D ? this : new CTBlockPos(new BlockPos((double) this.getX() + x, (double) this.getY() + y, (double) this.getZ() + z));
public MCBlockPos add(double x, double y, double z) {
return x == 0.0D && y == 0.0D && z == 0.0D ? this : new MCBlockPos(new BlockPos((double) this.getX() + x, (double) this.getY() + y, (double) this.getZ() + z));
}

/**
Expand All @@ -65,23 +64,22 @@ public CTBlockPos add(double x, double y, double z) {
* @docParam z -25
*/
@ZenCodeType.Method
public CTBlockPos add(int x, int y, int z) {
return x == 0 && y == 0 && z == 0 ? this : new CTBlockPos(new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z));

public MCBlockPos add(int x, int y, int z) {
return x == 0 && y == 0 && z == 0 ? this : new MCBlockPos(new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z));
}

/**
* Adds two positions together and returns the result.
*
* @param pos other position to add
*
* @return new {@link CTBlockPos} with the added values.
* @return new {@link MCBlockPos} with the added values.
*
* @docParam pos new BlockPos(3, 2, 1)
*/
@ZenCodeType.Method
@ZenCodeType.Operator(ZenCodeType.OperatorType.ADD)
public CTBlockPos add(CTBlockPos pos) {
public MCBlockPos add(MCBlockPos pos) {
return add(pos);
}

Expand All @@ -90,14 +88,14 @@ public CTBlockPos add(CTBlockPos pos) {
*
* @param pos other position to remove
*
* @return new {@link CTBlockPos} with the removed values.
* @return new {@link MCBlockPos} with the removed values.
*
* @docParam pos new BlockPos(2, 1, 3)
*/

@ZenCodeType.Method
@ZenCodeType.Operator(ZenCodeType.OperatorType.SUB)
public CTBlockPos subtract(CTBlockPos pos) {
public MCBlockPos subtract(MCBlockPos pos) {
return this.add(-pos.getX(), -pos.getY(), -pos.getZ());
}

Expand Down Expand Up @@ -231,29 +229,28 @@ public BlockPos east(int n) {
}

/**
* Creates a new BlockPos based on this BlockPos that is one block offset of this BlockPos based on the given {@link CTDirection}
* Creates a new BlockPos based on this BlockPos that is one block offset of this BlockPos based on the given {@link MCDirection}
*
* @return a new BlockPos that is 1 block offset of this BlockPos
*
* @docParam direction <direction:east>
*/
@ZenCodeType.Method
public CTBlockPos offset(CTDirection direction) {
public MCBlockPos offset(MCDirection direction) {
return offset(direction, 1);
}

/**
* Creates a new BlockPos based on this BlockPos that is n block(s) offset of this BlockPos based on the given {@link CTDirection}
* Creates a new BlockPos based on this BlockPos that is n block(s) offset of this BlockPos based on the given {@link MCDirection}
*
* @return a new BlockPos that is n block(s) offset of this BlockPos
*
* @docParam direction <direction:south>
* @docParam n 3
*/
@ZenCodeType.Method
public CTBlockPos offset(CTDirection direction, int n) {
return n == 0 ? this : new CTBlockPos(new BlockPos(this.getX() + direction.getXOffset() * n, this.getY() + direction.getYOffset() * n, this.getZ() + direction.getZOffset() * n));

public MCBlockPos offset(MCDirection direction, int n) {
return n == 0 ? this : new MCBlockPos(new BlockPos(this.getX() + direction.getXOffset() * n, this.getY() + direction.getYOffset() * n, this.getZ() + direction.getZOffset() * n));
}

/**
Expand All @@ -266,8 +263,8 @@ public CTBlockPos offset(CTDirection direction, int n) {
* @docParam pos new BlockPos(5, 8, 2);
*/
@ZenCodeType.Method
public CTBlockPos crossProduct(CTBlockPos pos) {
return new CTBlockPos(this.getY() * pos.getZ() - this.getZ() * pos.getY(), this.getZ() * pos.getX() - this.getX() * pos.getZ(), this.getX() * pos.getY() - this.getY() * pos.getX());
public MCBlockPos crossProduct(MCBlockPos pos) {
return new MCBlockPos(this.getY() * pos.getZ() - this.getZ() * pos.getY(), this.getZ() * pos.getX() - this.getX() * pos.getZ(), this.getX() * pos.getY() - this.getY() * pos.getX());
}

@ZenCodeType.Getter("x")
Expand Down Expand Up @@ -297,7 +294,7 @@ public int getZ() {
* @docParam distance 10
*/
@ZenCodeType.Method
public boolean withinDistance(CTBlockPos pos, double distance) {
public boolean withinDistance(MCBlockPos pos, double distance) {
return this.distanceSq(pos.getX(), pos.getY(), pos.getZ(), true) < distance * distance;
}

Expand All @@ -312,7 +309,7 @@ public boolean withinDistance(CTBlockPos pos, double distance) {
* @docParam useCenter true
*/
@ZenCodeType.Method
public double distanceSq(CTBlockPos to) {
public double distanceSq(MCBlockPos to) {
return this.distanceSq(to, true);
}

Expand All @@ -328,7 +325,7 @@ public double distanceSq(CTBlockPos to) {
* @docParam useCenter true
*/
@ZenCodeType.Method
public double distanceSq(CTBlockPos to, boolean useCenter) {
public double distanceSq(MCBlockPos to, boolean useCenter) {
return this.distanceSq(to.getX(), to.getY(), to.getZ(), useCenter);
}

Expand Down Expand Up @@ -362,7 +359,7 @@ public double distanceSq(double x, double y, double z, boolean useCenter) {
* @docParam other new BlockPos(4, 5, 6)
*/
@ZenCodeType.Method
public int manhattanDistance(CTBlockPos other) {
public int manhattanDistance(MCBlockPos other) {
return internal.manhattanDistance(other.getInternal());
}

Expand Down
Expand Up @@ -19,20 +19,20 @@
@ZenCodeType.Name("crafttweaker.api.util.Direction")
@Document("vanilla/util/Direction")
@ZenWrapper(wrappedClass = "net.minecraft.util.Direction", conversionMethodFormat = "%s.getInternal()", displayStringFormat = "%s.getInternal.toString()")
public class CTDirection {

private static final Map<Direction, CTDirection> DIRECTION_MAP = Util.make(new HashMap<>(), map -> {
map.put(Direction.NORTH, new CTDirection(Direction.NORTH));
map.put(Direction.SOUTH, new CTDirection(Direction.SOUTH));
map.put(Direction.EAST, new CTDirection(Direction.EAST));
map.put(Direction.WEST, new CTDirection(Direction.WEST));
map.put(Direction.UP, new CTDirection(Direction.UP));
map.put(Direction.DOWN, new CTDirection(Direction.DOWN));
public class MCDirection {

private static final Map<Direction, MCDirection> DIRECTION_MAP = Util.make(new HashMap<>(), map -> {
map.put(Direction.NORTH, new MCDirection(Direction.NORTH));
map.put(Direction.SOUTH, new MCDirection(Direction.SOUTH));
map.put(Direction.EAST, new MCDirection(Direction.EAST));
map.put(Direction.WEST, new MCDirection(Direction.WEST));
map.put(Direction.UP, new MCDirection(Direction.UP));
map.put(Direction.DOWN, new MCDirection(Direction.DOWN));
});

private Direction internal;

public CTDirection(Direction internal) {
public MCDirection(Direction internal) {
this.internal = internal;
}

Expand Down Expand Up @@ -78,7 +78,7 @@ public int getAxisOffset() {
* @return The opposite of this direction.
*/
@ZenCodeType.Getter("opposite")
public CTDirection getOpposite() {
public MCDirection getOpposite() {
return DIRECTION_MAP.get(internal.getOpposite());
}

Expand All @@ -92,7 +92,7 @@ public CTDirection getOpposite() {
* @docParam axis <directionaxis:north>
*/
@ZenCodeType.Method
public CTDirection rotateAround(CTDirectionAxis axis) {
public MCDirection rotateAround(MCDirectionAxis axis) {
return DIRECTION_MAP.get(internal.rotateAround(axis.getInternal()));
}

Expand All @@ -102,7 +102,7 @@ public CTDirection rotateAround(CTDirectionAxis axis) {
* @return the direction that rotated on the Y axis of this direction
*/
@ZenCodeType.Method
public CTDirection rotateY() {
public MCDirection rotateY() {
return DIRECTION_MAP.get(internal.rotateY());
}

Expand All @@ -112,7 +112,7 @@ public CTDirection rotateY() {
* @return the direction that is counter clockwise on the Y axis
*/
@ZenCodeType.Method
public CTDirection rotateYCCW() {
public MCDirection rotateYCCW() {
return DIRECTION_MAP.get(internal.rotateYCCW());
}

Expand Down Expand Up @@ -149,11 +149,11 @@ public int getZOffset() {
/**
* Gets the direction axis of this direction
*
* @return a {@link CTDirectionAxis} of this axis
* @return a {@link MCDirectionAxis} of this axis
*/
@ZenCodeType.Getter("axis")
public CTDirectionAxis getAxis() {
return CTDirectionAxis.getAxis(internal.getAxis());
public MCDirectionAxis getAxis() {
return MCDirectionAxis.getAxis(internal.getAxis());
}

/**
Expand Down
Expand Up @@ -20,17 +20,17 @@
@ZenCodeType.Name("crafttweaker.api.util.DirectionAxis")
@Document("vanilla/util/DirectionAxis")
@ZenWrapper(wrappedClass = "net.minecraft.util.Direction.Axis", conversionMethodFormat = "%s.getInternal()", displayStringFormat = "%s.getCommandString()")
public class CTDirectionAxis implements CommandStringDisplayable {
public class MCDirectionAxis implements CommandStringDisplayable {

private static final Map<Direction.Axis, CTDirectionAxis> AXIS_MAP = Util.make(new HashMap<>(), map -> {
map.put(Direction.Axis.X, new CTDirectionAxis(Direction.Axis.X));
map.put(Direction.Axis.Y, new CTDirectionAxis(Direction.Axis.Y));
map.put(Direction.Axis.Z, new CTDirectionAxis(Direction.Axis.Z));
private static final Map<Direction.Axis, MCDirectionAxis> AXIS_MAP = Util.make(new HashMap<>(), map -> {
map.put(Direction.Axis.X, new MCDirectionAxis(Direction.Axis.X));
map.put(Direction.Axis.Y, new MCDirectionAxis(Direction.Axis.Y));
map.put(Direction.Axis.Z, new MCDirectionAxis(Direction.Axis.Z));
});

private Direction.Axis internal;

public CTDirectionAxis(Direction.Axis internal) {
public MCDirectionAxis(Direction.Axis internal) {
this.internal = internal;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ public Direction.Axis getInternal() {
return internal;
}

public static CTDirectionAxis getAxis(Direction.Axis axis) {
public static MCDirectionAxis getAxis(Direction.Axis axis) {
return AXIS_MAP.get(axis);
}

Expand Down
Expand Up @@ -2,7 +2,7 @@

import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.impl.entity.MCEntityClassification;
import com.blamejared.crafttweaker.impl.util.CTBlockPos;
import com.blamejared.crafttweaker.impl.util.MCBlockPos;
import com.blamejared.crafttweaker_annotations.annotations.Document;
import com.blamejared.crafttweaker_annotations.annotations.ZenWrapper;
import net.minecraft.world.biome.Biome;
Expand Down Expand Up @@ -124,7 +124,7 @@ public String getTempCategory() {
}

@ZenCodeType.Method
public float getTemperature(CTBlockPos pos) {
public float getTemperature(MCBlockPos pos) {
return getInternal().getTemperature(pos.getInternal());
}

Expand Down

0 comments on commit 3313cae

Please sign in to comment.