Update bukkit registry related parts.
This commit is contained in:
parent
6cef5a799c
commit
b7e0f30898
@ -28,6 +28,7 @@ public class SwitchTableFixer implements Implementer {
|
|||||||
private static final Marker MARKER = MarkerManager.getMarker("SWITCH_TABLE");
|
private static final Marker MARKER = MarkerManager.getMarker("SWITCH_TABLE");
|
||||||
private static final Set<String> ENUMS = ImmutableSet.<String>builder()
|
private static final Set<String> ENUMS = ImmutableSet.<String>builder()
|
||||||
.add("org/bukkit/Material")
|
.add("org/bukkit/Material")
|
||||||
|
.add("org/bukkit/entity/EntityType")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public byte[] processClass(byte[] bytes) {
|
public byte[] processClass(byte[] bytes) {
|
||||||
|
|||||||
@ -18,6 +18,10 @@ public interface MaterialBridge {
|
|||||||
|
|
||||||
void bridge$setupItem(ResourceLocation key, Item item, MaterialPropertySpec spec);
|
void bridge$setupItem(ResourceLocation key, Item item, MaterialPropertySpec spec);
|
||||||
|
|
||||||
|
void bridge$setBlock();
|
||||||
|
|
||||||
|
void bridge$setItem();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
MaterialPropertySpec bridge$getSpec();
|
MaterialPropertySpec bridge$getSpec();
|
||||||
|
|
||||||
|
|||||||
@ -88,18 +88,29 @@ public abstract class MaterialMixin implements MaterialBridge {
|
|||||||
|
|
||||||
private MaterialPropertySpec.MaterialType arclight$type = MaterialPropertySpec.MaterialType.VANILLA;
|
private MaterialPropertySpec.MaterialType arclight$type = MaterialPropertySpec.MaterialType.VANILLA;
|
||||||
private MaterialPropertySpec arclight$spec;
|
private MaterialPropertySpec arclight$spec;
|
||||||
|
private boolean arclight$block = false, arclight$item = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bridge$setBlock() {
|
||||||
|
this.arclight$block = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bridge$setItem() {
|
||||||
|
this.arclight$item = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "isBlock", cancellable = true, at = @At("HEAD"))
|
@Inject(method = "isBlock", cancellable = true, at = @At("HEAD"))
|
||||||
private void arclight$isBlock(CallbackInfoReturnable<Boolean> cir) {
|
private void arclight$isBlock(CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (arclight$type != MaterialPropertySpec.MaterialType.VANILLA) {
|
if (arclight$type != MaterialPropertySpec.MaterialType.VANILLA) {
|
||||||
cir.setReturnValue(arclight$type == MaterialPropertySpec.MaterialType.FORGE_BLOCK);
|
cir.setReturnValue(arclight$block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "isItem", cancellable = true, at = @At("HEAD"))
|
@Inject(method = "isItem", cancellable = true, at = @At("HEAD"))
|
||||||
private void arclight$isItem(CallbackInfoReturnable<Boolean> cir) {
|
private void arclight$isItem(CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (arclight$type != MaterialPropertySpec.MaterialType.VANILLA) {
|
if (arclight$type != MaterialPropertySpec.MaterialType.VANILLA) {
|
||||||
cir.setReturnValue(arclight$type == MaterialPropertySpec.MaterialType.FORGE_ITEM);
|
cir.setReturnValue(arclight$item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,14 +249,16 @@ public abstract class MaterialMixin implements MaterialBridge {
|
|||||||
@Override
|
@Override
|
||||||
public void bridge$setupBlock(ResourceLocation key, Block block, MaterialPropertySpec spec) {
|
public void bridge$setupBlock(ResourceLocation key, Block block, MaterialPropertySpec spec) {
|
||||||
this.arclight$spec = spec.clone();
|
this.arclight$spec = spec.clone();
|
||||||
arclight$type = MaterialPropertySpec.MaterialType.FORGE_BLOCK;
|
arclight$type = MaterialPropertySpec.MaterialType.FORGE;
|
||||||
|
arclight$block = true;
|
||||||
arclight$setupCommon(key, block, block.asItem());
|
arclight$setupCommon(key, block, block.asItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bridge$setupItem(ResourceLocation key, Item item, MaterialPropertySpec spec) {
|
public void bridge$setupItem(ResourceLocation key, Item item, MaterialPropertySpec spec) {
|
||||||
this.arclight$spec = spec.clone();
|
this.arclight$spec = spec.clone();
|
||||||
arclight$type = MaterialPropertySpec.MaterialType.FORGE_ITEM;
|
arclight$type = MaterialPropertySpec.MaterialType.FORGE;
|
||||||
|
arclight$item = true;
|
||||||
arclight$setupCommon(key, null, item);
|
arclight$setupCommon(key, null, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,6 +129,12 @@ public class BukkitRegistry {
|
|||||||
}
|
}
|
||||||
BLOCK_MATERIAL.put(block, material);
|
BLOCK_MATERIAL.put(block, material);
|
||||||
MATERIAL_BLOCK.put(material, block);
|
MATERIAL_BLOCK.put(material, block);
|
||||||
|
Item value = ForgeRegistries.ITEMS.getValue(location);
|
||||||
|
if (value != null) {
|
||||||
|
((MaterialBridge) (Object) material).bridge$setItem();
|
||||||
|
ITEM_MATERIAL.put(value, material);
|
||||||
|
MATERIAL_ITEM.put(material, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<ResourceLocation, Item> entry : ForgeRegistries.ITEMS.getEntries()) {
|
for (Map.Entry<ResourceLocation, Item> entry : ForgeRegistries.ITEMS.getEntries()) {
|
||||||
ResourceLocation location = entry.getKey();
|
ResourceLocation location = entry.getKey();
|
||||||
@ -146,6 +152,12 @@ public class BukkitRegistry {
|
|||||||
}
|
}
|
||||||
ITEM_MATERIAL.put(item, material);
|
ITEM_MATERIAL.put(item, material);
|
||||||
MATERIAL_ITEM.put(material, item);
|
MATERIAL_ITEM.put(material, item);
|
||||||
|
Block value = ForgeRegistries.BLOCKS.getValue(location);
|
||||||
|
if (value != null) {
|
||||||
|
((MaterialBridge) (Object) material).bridge$setBlock();
|
||||||
|
BLOCK_MATERIAL.put(value, material);
|
||||||
|
MATERIAL_BLOCK.put(material, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EnumHelper.addEnums(Material.class, list);
|
EnumHelper.addEnums(Material.class, list);
|
||||||
ArclightMod.LOGGER.info("registry.material", i - origin, blocks, items);
|
ArclightMod.LOGGER.info("registry.material", i - origin, blocks, items);
|
||||||
|
|||||||
@ -75,6 +75,6 @@ public class MaterialPropertySpec implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum MaterialType {
|
public enum MaterialType {
|
||||||
VANILLA, FORGE_BLOCK, FORGE_ITEM
|
VANILLA, FORGE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user