mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Allow NonVanillaCustomItemData to have a block assigned (#4530)
This commit is contained in:
parent
b469904951
commit
fbafdbb2a7
3 changed files with 31 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -161,6 +161,13 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
||||||
return displayHandheld();
|
return displayHandheld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the block the item places.
|
||||||
|
*
|
||||||
|
* @return the block the item places
|
||||||
|
*/
|
||||||
|
String block();
|
||||||
|
|
||||||
static NonVanillaCustomItemData.Builder builder() {
|
static NonVanillaCustomItemData.Builder builder() {
|
||||||
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
|
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
|
||||||
}
|
}
|
||||||
|
@ -201,6 +208,8 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
||||||
|
|
||||||
Builder chargeable(boolean isChargeable);
|
Builder chargeable(boolean isChargeable);
|
||||||
|
|
||||||
|
Builder block(String block);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #displayHandheld(boolean)} instead.
|
* @deprecated Use {@link #displayHandheld(boolean)} instead.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -55,6 +55,7 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
private final boolean isEdible;
|
private final boolean isEdible;
|
||||||
private final boolean canAlwaysEat;
|
private final boolean canAlwaysEat;
|
||||||
private final boolean isChargeable;
|
private final boolean isChargeable;
|
||||||
|
private final String block;
|
||||||
|
|
||||||
public GeyserNonVanillaCustomItemData(Builder builder) {
|
public GeyserNonVanillaCustomItemData(Builder builder) {
|
||||||
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.allowOffhand,
|
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.allowOffhand,
|
||||||
|
@ -78,6 +79,7 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
this.isEdible = builder.edible;
|
this.isEdible = builder.edible;
|
||||||
this.canAlwaysEat = builder.canAlwaysEat;
|
this.canAlwaysEat = builder.canAlwaysEat;
|
||||||
this.isChargeable = builder.chargeable;
|
this.isChargeable = builder.chargeable;
|
||||||
|
this.block = builder.block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -160,6 +162,11 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
return isChargeable;
|
return isChargeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String block() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder {
|
public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder {
|
||||||
private String identifier = null;
|
private String identifier = null;
|
||||||
private int javaId = -1;
|
private int javaId = -1;
|
||||||
|
@ -186,6 +193,7 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
private boolean edible = false;
|
private boolean edible = false;
|
||||||
private boolean canAlwaysEat = false;
|
private boolean canAlwaysEat = false;
|
||||||
private boolean chargeable = false;
|
private boolean chargeable = false;
|
||||||
|
private String block = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder name(@NonNull String name) {
|
public Builder name(@NonNull String name) {
|
||||||
|
@ -339,6 +347,12 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder block(String block) {
|
||||||
|
this.block = block;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NonVanillaCustomItemData build() {
|
public NonVanillaCustomItemData build() {
|
||||||
if (identifier == null || javaId == -1) {
|
if (identifier == null || javaId == -1) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -248,6 +248,11 @@ public class CustomItemRegistryPopulator {
|
||||||
itemProperties.putBoolean("foil", true);
|
itemProperties.putBoolean("foil", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String block = customItemData.block();
|
||||||
|
if (block != null) {
|
||||||
|
computeBlockItemProperties(block, componentBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
componentBuilder.putCompound("item_properties", itemProperties.build());
|
componentBuilder.putCompound("item_properties", itemProperties.build());
|
||||||
builder.putCompound("components", componentBuilder.build());
|
builder.putCompound("components", componentBuilder.build());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue