Skip to content

Commit

Permalink
1.21.4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
pisaiah committed Jan 17, 2025
1 parent a4bc49d commit 0d08dd9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.TeleportTarget;
import net.minecraft.world.World;

@SupportedVersion({"1.17"})
@Mixin(Entity.class)
public class MixinEntity implements IMixinEntity {

@Override
public void Iremove(IRemoveReason r) {
Entity thiz = ((Entity)(Object)this);

switch (r) {
case DIMENSION_CHANGE:
removeFromDimension();
Expand All @@ -39,7 +42,11 @@ public void Iremove(IRemoveReason r) {
discard();
break;
case KILLED:
kill();

World world = thiz.getWorld();
if (world instanceof ServerWorld) {
kill( (ServerWorld) world );
}
break;
default:
ICommonMod.LOGGER.warn("Unknown RemoveReason: " + r.toString());
Expand All @@ -55,7 +62,7 @@ public IEntity getAsICommon() {
return icommon;
}

@Shadow public void kill() {} // Dimension change
@Shadow public void kill(ServerWorld world) {} // Dimension change
@Shadow public void discard() {} // Discard
@Shadow public void removeFromDimension() {} // Kill

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.isaiah.common.mixin.R1_21;

import java.util.Optional;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

Expand All @@ -16,12 +18,15 @@ public class MixinMobEntity implements IMixinMobEntity {
// <=1.20.4: Lnet/minecraft/entity/mob/MobEntity;lootTable:Lnet/minecraft/util/Identifier;
// >=1.20.5: Lnet/minecraft/entity/mob/MobEntity;lootTable:Lnet/minecraft/registry/RegistryKey;

@Shadow
public RegistryKey<LootTable> lootTable;
//@Shadow
//public RegistryKey<LootTable> lootTable;

@Shadow
public Optional<RegistryKey<LootTable>> lootTable; // = Optional.empty();

@Override
public void IC$set_loot_table(Identifier id) {
this.lootTable = IC$identifier_to_table(id);
this.lootTable = Optional.of(IC$identifier_to_table(id));
}

private RegistryKey<net.minecraft.loot.LootTable> IC$identifier_to_table(Identifier key) {
Expand All @@ -32,10 +37,10 @@ public class MixinMobEntity implements IMixinMobEntity {
public Identifier IC$get_loot_table_id() {
MobEntity e = ((MobEntity) (Object) this);

if (lootTable == null) {
lootTable = e.getLootTableKey().get();
if (lootTable == null || lootTable.isEmpty()) {
lootTable = Optional.of( e.getLootTableKey().get() );
}
return lootTable.getValue();
return lootTable.get().getValue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class MixinWorld_18 implements IMixinWorld {

@SuppressWarnings("resource")
@Inject(method = "<init>", at = @At("TAIL"))
public void init(MutableWorldProperties a, RegistryKey<?> b, DynamicRegistryManager rm, RegistryEntry<DimensionType> registryEntry, Supplier<Profiler> profiler, boolean f, boolean g, long h, int i, CallbackInfo ci){
public void init(MutableWorldProperties a, RegistryKey<?> b, DynamicRegistryManager rm, RegistryEntry<DimensionType> registryEntry, boolean f, boolean g, long h, int i, CallbackInfo ci){
// public void init(MutableWorldProperties a, RegistryKey<?> b, DynamicRegistryManager rm, RegistryEntry<DimensionType> registryEntry, Supplier<Profiler> profiler, boolean f, boolean g, long h, int i, CallbackInfo ci){
// public void init(MutableWorldProperties a, RegistryKey<?> b, RegistryEntry<DimensionType> registryEntry, Supplier<Profiler> profiler, boolean f, boolean g, long h, int i, CallbackInfo ci){
// public void init(MutableWorldProperties a, RegistryKey<?> b, DimensionType d, Supplier<Profiler> e, boolean f, boolean g, long h, CallbackInfo ci){
if (!((Object)this instanceof ServerWorld)) {
Expand Down

0 comments on commit 0d08dd9

Please sign in to comment.