Skip to content

Commit

Permalink
Merge in master, adapt to changes in the MappingsReader, delete unuse…
Browse files Browse the repository at this point in the history
…d ToolBreakSpeedsUtils class
  • Loading branch information
onebeastchris committed Aug 24, 2023
1 parent 874ffa3 commit ea84f49
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ public interface CustomItemData {
*/
@NonNull String icon();

/**
* Gets the item's tags to use in Molang.
*
* @return the item's tags, if they exist
*/
@Nullable Set<String> tags();

/**
* Gets if the item is allowed to be put into the offhand.
*
Expand Down Expand Up @@ -98,6 +91,13 @@ public interface CustomItemData {
*/
@Nullable CustomRenderOffsets renderOffsets();

/**
* Gets the item's tags to use in Molang.
*
* @return the item's tags, if they exist
*/
@Nullable Set<String> tags();

static CustomItemData.Builder builder() {
return GeyserApi.api().provider(CustomItemData.Builder.class);
}
Expand All @@ -114,8 +114,6 @@ interface Builder {

Builder icon(@NonNull String icon);

Builder tags(@Nullable Set<String> tags);

Builder allowOffhand(boolean allowOffhand);

Builder displayHandheld(boolean displayHandheld);
Expand All @@ -124,6 +122,8 @@ interface Builder {

Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets);

Builder tags(@Nullable Set<String> tags);

CustomItemData build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.geysermc.geyser.api.item.custom.CustomRenderOffsets;
import org.jetbrains.annotations.NotNull;

import java.util.HashSet;
import java.util.Set;

@EqualsAndHashCode
Expand All @@ -43,30 +44,30 @@ public class GeyserCustomItemData implements CustomItemData {
private final CustomItemOptions customItemOptions;
private final String displayName;
private final String icon;
private final Set<String> tags;
private final boolean allowOffhand;
private final boolean displayHandheld;
private final int textureSize;
private final CustomRenderOffsets renderOffsets;
private final Set<String> tags;

public GeyserCustomItemData(String name,
CustomItemOptions customItemOptions,
String displayName,
String icon,
Set<String> tags,
boolean allowOffhand,
boolean displayHandheld,
int textureSize,
CustomRenderOffsets renderOffsets) {
CustomRenderOffsets renderOffsets,
Set<String> tags) {
this.name = name;
this.customItemOptions = customItemOptions;
this.displayName = displayName;
this.icon = icon;
this.tags = tags;
this.allowOffhand = allowOffhand;
this.displayHandheld = displayHandheld;
this.textureSize = textureSize;
this.renderOffsets = renderOffsets;
this.tags = tags;
}

@Override
Expand All @@ -89,11 +90,6 @@ public CustomItemOptions customItemOptions() {
return icon;
}

@Override
public @Nullable Set<String> tags() {
return tags;
}

@Override
public boolean allowOffhand() {
return allowOffhand;
Expand All @@ -114,17 +110,22 @@ public CustomRenderOffsets renderOffsets() {
return renderOffsets;
}

@Override
public @Nullable Set<String> tags() {
return tags;
}

public static class CustomItemDataBuilder implements Builder {
protected String name = null;
protected CustomItemOptions customItemOptions = null;

protected String displayName = null;
protected String icon = null;
protected Set<String> tags = null;
protected boolean allowOffhand = true; // Bedrock doesn't give items offhand allowance unless they serve gameplay purpose, but we want to be friendly with Java
protected boolean displayHandheld = false;
protected int textureSize = 16;
protected CustomRenderOffsets renderOffsets = null;
protected Set<String> tags = new HashSet<>();

@Override
public Builder name(@NonNull String name) {
Expand All @@ -150,12 +151,6 @@ public Builder icon(@NonNull String icon) {
return this;
}

@Override
public Builder tags(@Nullable Set<String> tags) {
this.tags = tags;
return this;
}

@Override
public Builder allowOffhand(boolean allowOffhand) {
this.allowOffhand = allowOffhand;
Expand All @@ -180,6 +175,12 @@ public Builder renderOffsets(CustomRenderOffsets renderOffsets) {
return this;
}

@Override
public Builder tags(Set<String> tags) {
this.tags.addAll(tags);
return this;
}

@Override
public CustomItemData build() {
if (this.name == null || this.customItemOptions == null) {
Expand All @@ -192,7 +193,7 @@ public CustomItemData build() {
if (this.icon == null) {
this.icon = this.name;
}
return new GeyserCustomItemData(this.name, this.customItemOptions, this.displayName, this.icon, this.tags, this.allowOffhand, this.displayHandheld, this.textureSize, this.renderOffsets);
return new GeyserCustomItemData(this.name, this.customItemOptions, this.displayName, this.icon, this.allowOffhand, this.displayHandheld, this.textureSize, this.renderOffsets, this.tags);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
private final boolean isChargeable;

public GeyserNonVanillaCustomItemData(NonVanillaCustomItemDataBuilder builder) {
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.tags, builder.allowOffhand,
builder.displayHandheld, builder.textureSize, builder.renderOffsets);
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.allowOffhand,
builder.displayHandheld, builder.textureSize, builder.renderOffsets, builder.tags);

this.identifier = builder.identifier;
this.javaId = builder.javaId;
Expand Down Expand Up @@ -227,11 +227,6 @@ public NonVanillaCustomItemData.Builder icon(@NonNull String icon) {
return (NonVanillaCustomItemData.Builder) super.icon(icon);
}

@Override
public NonVanillaCustomItemData.Builder tags(@Nullable Set<String> tags) {
return (NonVanillaCustomItemData.Builder) super.tags(tags);
}

@Override
public NonVanillaCustomItemData.Builder textureSize(int textureSize) {
return (NonVanillaCustomItemData.Builder) super.textureSize(textureSize);
Expand All @@ -242,6 +237,11 @@ public NonVanillaCustomItemData.Builder renderOffsets(CustomRenderOffsets render
return (NonVanillaCustomItemData.Builder) super.renderOffsets(renderOffsets);
}

@Override
public NonVanillaCustomItemData.Builder tags(@Nullable Set<String> tags) {
return (NonVanillaCustomItemData.Builder) super.tags(tags);
}

@Override
public NonVanillaCustomItemData.Builder identifier(@NonNull String identifier) {
this.identifier = identifier;
Expand Down

This file was deleted.

Empty file.
Loading

0 comments on commit ea84f49

Please sign in to comment.