Skip to content

Commit

Permalink
Fix thrown egg NPE (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jan 26, 2024
1 parent 132b181 commit 600f108
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package io.izzel.arclight.common.bridge.bukkit;

import io.izzel.arclight.i18n.conf.EntityPropertySpec;
import org.bukkit.Location;

import java.util.function.Function;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import org.bukkit.Location;

import java.util.function.Function;

public interface EntityTypeBridge {

void bridge$setup(ResourceLocation location, EntityType<?> entityType, EntityPropertySpec spec);

EntityType<?> bridge$getHandle();

void bridge$setHandle(EntityType<?> entityType);

EntityPropertySpec bridge$getSpec();

Function<Location, ? extends Entity> bridge$entityFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import io.izzel.arclight.common.mod.ArclightMod;
import io.izzel.arclight.i18n.LocalizedException;
import io.izzel.arclight.i18n.conf.EntityPropertySpec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v.CraftWorld;
Expand All @@ -16,8 +18,6 @@
import org.spongepowered.asm.mixin.Shadow;

import java.util.function.Function;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;

@Mixin(value = EntityType.class, remap = false)
public class EntityTypeMixin implements EntityTypeBridge {
Expand Down Expand Up @@ -75,6 +75,11 @@ private void setup() {
return this.handleType;
}

@Override
public void bridge$setHandle(net.minecraft.world.entity.EntityType<?> entityType) {
this.handleType = entityType;
}

@Override
public EntityPropertySpec bridge$getSpec() {
return spec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ private static void loadEntities() {
boolean found = false;
if (location.getNamespace().equals(NamespacedKey.MINECRAFT)) {
entityType = EntityType.fromName(location.getPath());
if (entityType != null) found = true;
if (entityType != null) {
found = true;
((EntityTypeBridge) (Object) entityType).bridge$setHandle(type);
}
else ArclightMod.LOGGER.warn("Not found {} in {}", location, EntityType.class);
}
if (!found) {
Expand Down

0 comments on commit 600f108

Please sign in to comment.