Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Mar 13, 2022
1 parent 384e13f commit a60af3e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
Expand Up @@ -26,7 +26,6 @@ public Percentaged(T data, double percentage, Function<T, String> commandStringF
this.commandStringFunc = commandStringFunc;
}


public T getData() {

return data;
Expand Down
Expand Up @@ -72,6 +72,7 @@ public static String getLootTable(Block internal) {
* @return True if an entity can be spawned in this Block. False Otherwise.
*/
@ZenCodeType.Method
@ZenCodeType.Getter("isPossibleToRespawnInThis")
public static boolean isPossibleToRespawnInThis(Block internal) {

return internal.isPossibleToRespawnInThis();
Expand All @@ -83,7 +84,7 @@ public static boolean isPossibleToRespawnInThis(Block internal) {
* @return The unlocalized name of this block.
*/
@ZenCodeType.Method
@ZenCodeType.Getter("translationKey")
@ZenCodeType.Getter("getDescriptionId")
public static String getDescriptionId(Block internal) {

return internal.getDescriptionId();
Expand Down Expand Up @@ -113,7 +114,7 @@ public static String getCommandString(Block internal) {
* @return A list of valid {@link BlockState}s for this Block.
*/
@ZenCodeType.Method
@ZenCodeType.Getter("validStates")
@ZenCodeType.Getter("possibleStates")
public static List<BlockState> getPossibleStates(Block internal) {

return internal.getStateDefinition().getPossibleStates();
Expand Down Expand Up @@ -154,9 +155,9 @@ public static float getFriction(Block internal) {
*/
@ZenCodeType.Method
@ZenCodeType.Setter("friction")
public static void setSlipperiness(Block internal, float friction) {
public static void setFriction(Block internal, float friction) {

CraftTweakerAPI.apply(new ActionSetBlockProperty<>(internal, "Slipperiness",
CraftTweakerAPI.apply(new ActionSetBlockProperty<>(internal, "Friction",
friction, ((AccessBlockBehaviour) internal).crafttweaker$getFriction(), ((AccessBlockBehaviour) internal)::crafttweaker$setFriction));
}

Expand Down Expand Up @@ -262,7 +263,7 @@ public static boolean hasCollision(Block internal) {
* @docParam canCollide true
*/
@ZenCodeType.Method
@ZenCodeType.Setter("canCollide")
@ZenCodeType.Setter("hasCollision")
public static void setHasCollision(Block internal, boolean canCollide) {

CraftTweakerAPI.apply(new ActionSetBlockProperty<>(internal, "Has Collision",
Expand Down
Expand Up @@ -77,7 +77,7 @@ public static int getLightEmission(BlockState internal) {
* @return True if this BlockState can provide Redstone Power. False otherwise.
*/
@ZenCodeType.Method
@ZenCodeType.Getter("signalSource")
@ZenCodeType.Getter("isSignalSource")
public static boolean isSignalSource(BlockState internal) {

return internal.isSignalSource();
Expand All @@ -101,7 +101,7 @@ public static boolean canOcclude(BlockState internal) {
* @return True if this BlockState ticks randomly. False otherwise.
*/
@ZenCodeType.Method
@ZenCodeType.Getter("randomlyTicking")
@ZenCodeType.Getter("isRandomlyTicking")
public static boolean isRandomlyTicking(BlockState internal) {

return internal.isRandomlyTicking();
Expand Down Expand Up @@ -209,6 +209,7 @@ public static List<String> getAllowedValuesForProperty(BlockState internal, Stri
* @return a Map of the properties on this BlockState.
*/
@ZenCodeType.Method
@ZenCodeType.Getter("properties")
public static Map<String, String> getProperties(BlockState internal) {

Map<String, String> props = new HashMap<>();
Expand All @@ -234,9 +235,8 @@ public static boolean hasProperty(BlockState internal, String name) {
return prop != null;
}

@ZenCodeType.Caster
@ZenCodeType.Method
public static String asString(BlockState internal) {

return internal.toString();
}

Expand All @@ -261,7 +261,7 @@ public static float getDestroySpeed(BlockState internal) {
*/
@ZenCodeType.Method
@ZenCodeType.Setter("destroySpeed")
public static void setHardness(BlockState internal, float destroySpeed) {
public static void setDestroySpeed(BlockState internal, float destroySpeed) {

CraftTweakerAPI.apply(new ActionSetBlockProperty<>(internal, "Destroy Speed", destroySpeed, ((AccessBlockStateBase) internal).crafttweaker$getDestroySpeed(), value -> ((AccessBlockStateBase) internal).crafttweaker$setDestroySpeed(value)));
}
Expand All @@ -278,6 +278,7 @@ public static void setHardness(BlockState internal, float destroySpeed) {
*/
@ZenCodeType.Method
@ZenCodeType.Getter("commandString")
@ZenCodeType.Caster
public static String getCommandString(BlockState internal) {

StringBuilder builder = new StringBuilder("<blockstate:");
Expand Down
Expand Up @@ -36,6 +36,12 @@ public static MapData getData(BlockEntity internal) {
return new MapData(internal.saveWithoutMetadata());
}

@ZenCodeType.Method
@ZenCodeType.Setter("data")
public static void setData(BlockEntity internal, MapData data){
internal.load(data.getInternal());
}

@ZenCodeType.Method
public static void updateData(BlockEntity internal, MapData data) {

Expand Down
Expand Up @@ -63,6 +63,7 @@ public static boolean isClientSyncable(Attribute internal) {
*/
@ZenCodeType.Method
@ZenCodeType.Getter("commandString")
@ZenCodeType.Caster
public static String getCommandString(Attribute internal) {

return "<attribute:" + Services.REGISTRY.getRegistryKey(internal) + ">";
Expand Down
Expand Up @@ -16,24 +16,28 @@
@NativeTypeRegistration(value = AttributeInstance.class, zenCodeName = "crafttweaker.api.entity.attribute.AttributeInstance")
public class ExpandAttributeInstance {

@ZenCodeType.Method
@ZenCodeType.Getter("baseValue")
public static double getBaseValue(AttributeInstance internal) {

return internal.getBaseValue();
}

@ZenCodeType.Method
@ZenCodeType.Setter("baseValue")
public static void setBaseValue(AttributeInstance internal, double value) {

internal.setBaseValue(value);
}

@ZenCodeType.Method
@ZenCodeType.Getter("value")
public static double getValue(AttributeInstance internal) {

return internal.getValue();
}

@ZenCodeType.Method
@ZenCodeType.Getter("modifiers")
public static List<AttributeModifier> getModifiers(AttributeInstance internal) {

Expand Down

0 comments on commit a60af3e

Please sign in to comment.