1.16: chunks, goals, containers and tile entities

This commit is contained in:
IzzelAliz 2020-08-21 15:04:24 +08:00
parent 35c30347a7
commit 026df6e51f
34 changed files with 524 additions and 308 deletions

View File

@ -2,8 +2,13 @@ package io.izzel.arclight.common.bridge.tileentity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import java.util.List;
public interface AbstractFurnaceTileEntityBridge {
void bridge$dropExp(PlayerEntity entity, ItemStack itemStack, int amount);
List<IRecipe<?>> bridge$dropExp(World world, Vector3d pos, PlayerEntity entity, ItemStack itemStack, int amount);
}

View File

@ -8,4 +8,6 @@ public interface IWorldWriterBridge {
boolean bridge$addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason);
void bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason reason);
CreatureSpawnEvent.SpawnReason bridge$getAddEntityReason();
}

View File

@ -0,0 +1,12 @@
package io.izzel.arclight.common.bridge.world.storage;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.Dimension;
import net.minecraft.world.storage.SaveFormat;
import java.io.IOException;
public interface SaveFormatBridge {
SaveFormat.LevelSave bridge$getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException;
}

View File

@ -0,0 +1,26 @@
package io.izzel.arclight.common.mixin.core.command.impl;
import net.minecraft.command.impl.ReloadCommand;
import net.minecraft.resources.ResourcePackList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.storage.IServerConfiguration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Collection;
@Mixin(ReloadCommand.class)
public abstract class ReloadCommandMixin {
// @formatter:off
@Shadow private static Collection<String> func_241058_a_(ResourcePackList p_241058_0_, IServerConfiguration p_241058_1_, Collection<String> p_241058_2_) { return null; }
// @formatter:on
private static void reload(MinecraftServer minecraftserver) {
ResourcePackList resourcePackList = minecraftserver.getResourcePacks();
IServerConfiguration configuration = minecraftserver.func_240793_aU_();
Collection<String> collection = resourcePackList.func_232621_d_();
Collection<String> collection2 = func_241058_a_(resourcePackList, configuration, collection);
minecraftserver.func_240780_a_(collection2);
}
}

View File

@ -1,22 +0,0 @@
package io.izzel.arclight.common.mixin.core.command.impl;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.command.CommandSource;
import net.minecraft.command.impl.SummonCommand;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(SummonCommand.class)
public class SummonCommandMixin {
@Inject(method = "summonEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addLightningBolt(Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
private static void arclight$strikeReason(CommandSource source, ResourceLocation type, Vec3d pos, CompoundNBT nbt, boolean randomizeProperties, CallbackInfoReturnable<Integer> cir) {
((ServerWorldBridge) source.getWorld()).bridge$pushStrikeLightningCause(LightningStrikeEvent.Cause.COMMAND);
}
}

View File

@ -1,10 +1,12 @@
package io.izzel.arclight.common.mixin.core.command.impl;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.command.CommandSource;
import net.minecraft.command.impl.TeleportCommand;
import net.minecraft.entity.CreatureEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@ -12,15 +14,17 @@ import net.minecraft.network.play.server.SPlayerPositionLookPacket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.server.TicketType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import javax.annotation.Nullable;
import java.util.Set;
@ -28,75 +32,85 @@ import java.util.Set;
@Mixin(TeleportCommand.class)
public class TeleportCommandMixin {
// @formatter:off
@Shadow @Final private static SimpleCommandExceptionType field_241077_a_;
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private static void teleport(CommandSource source, Entity entityIn, ServerWorld worldIn, double x, double y, double z, Set<SPlayerPositionLookPacket.Flags> relativeList, float yaw, float pitch, @Nullable TeleportCommand.Facing facing) {
if (entityIn instanceof ServerPlayerEntity) {
ChunkPos chunkpos = new ChunkPos(new BlockPos(x, y, z));
worldIn.getChunkProvider().registerTicket(TicketType.POST_TELEPORT, chunkpos, 1, entityIn.getEntityId());
entityIn.stopRiding();
if (((ServerPlayerEntity) entityIn).isSleeping()) {
((ServerPlayerEntity) entityIn).stopSleepInBed(true, true);
}
((ServerPlayNetHandlerBridge) ((ServerPlayerEntity) entityIn).connection).bridge$pushTeleportCause(PlayerTeleportEvent.TeleportCause.COMMAND);
if (worldIn == entityIn.world) {
((ServerPlayerEntity) entityIn).connection.setPlayerLocation(x, y, z, yaw, pitch, relativeList);
} else {
((ServerPlayerEntity) entityIn).teleport(worldIn, x, y, z, yaw, pitch);
}
entityIn.setRotationYawHead(yaw);
private static void teleport(CommandSource source, Entity entityIn, ServerWorld worldIn, double x, double y, double z, Set<SPlayerPositionLookPacket.Flags> relativeList, float yaw, float pitch, @Nullable TeleportCommand.Facing facing) throws CommandSyntaxException {
BlockPos blockpos = new BlockPos(x, y, z);
if (!World.isInvalidPosition(blockpos)) {
throw field_241077_a_.create();
} else {
float f1 = MathHelper.wrapDegrees(yaw);
float f = MathHelper.wrapDegrees(pitch);
f = MathHelper.clamp(f, -90.0F, 90.0F);
Location to = new Location(((ServerWorldBridge) worldIn).bridge$getWorld(), x, y, z, f1, f);
EntityTeleportEvent event = new EntityTeleportEvent(((EntityBridge) entityIn).bridge$getBukkitEntity(), ((EntityBridge) entityIn).bridge$getBukkitEntity().getLocation(), to);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
to = event.getTo();
x = to.getX();
y = to.getY();
z = to.getZ();
f1 = to.getYaw();
f = to.getPitch();
worldIn = ((CraftWorld) to.getWorld()).getHandle();
if (worldIn == entityIn.world) {
entityIn.setLocationAndAngles(x, y, z, f1, f);
entityIn.setRotationYawHead(f1);
} else {
entityIn.detach();
entityIn.dimension = worldIn.dimension.getType();
Entity entity = entityIn;
entityIn = entityIn.getType().create(worldIn);
if (entityIn == null) {
return;
if (entityIn instanceof ServerPlayerEntity) {
ChunkPos chunkpos = new ChunkPos(new BlockPos(x, y, z));
worldIn.getChunkProvider().registerTicket(TicketType.POST_TELEPORT, chunkpos, 1, entityIn.getEntityId());
entityIn.stopRiding();
if (((ServerPlayerEntity) entityIn).isSleeping()) {
((ServerPlayerEntity) entityIn).stopSleepInBed(true, true);
}
entityIn.copyDataFromOld(entity);
entityIn.setLocationAndAngles(x, y, z, f1, f);
entityIn.setRotationYawHead(f1);
worldIn.addFromAnotherDimension(entityIn);
entity.removed = true;
if (worldIn == entityIn.world) {
((ServerPlayerEntity) entityIn).connection.setPlayerLocation(x, y, z, yaw, pitch, relativeList);
} else {
((ServerPlayerEntity) entityIn).teleport(worldIn, x, y, z, yaw, pitch);
}
entityIn.setRotationYawHead(yaw);
} else {
float f1 = MathHelper.wrapDegrees(yaw);
float f = MathHelper.wrapDegrees(pitch);
f = MathHelper.clamp(f, -90.0F, 90.0F);
Location to = new Location(((ServerWorldBridge) worldIn).bridge$getWorld(), x, y, z, f1, f);
EntityTeleportEvent event = new EntityTeleportEvent(((EntityBridge) entityIn).bridge$getBukkitEntity(), ((EntityBridge) entityIn).bridge$getBukkitEntity().getLocation(), to);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
to = event.getTo();
x = to.getX();
y = to.getY();
z = to.getZ();
f1 = to.getYaw();
f = to.getPitch();
worldIn = ((CraftWorld) to.getWorld()).getHandle();
if (worldIn == entityIn.world) {
entityIn.setLocationAndAngles(x, y, z, f1, f);
entityIn.setRotationYawHead(f1);
} else {
entityIn.detach();
Entity entity = entityIn;
entityIn = entityIn.getType().create(worldIn);
if (entityIn == null) {
return;
}
entityIn.copyDataFromOld(entity);
entityIn.setLocationAndAngles(x, y, z, f1, f);
entityIn.setRotationYawHead(f1);
worldIn.addFromAnotherDimension(entityIn);
}
}
}
if (facing != null) {
facing.updateLook(source, entityIn);
}
if (facing != null) {
facing.updateLook(source, entityIn);
}
if (!(entityIn instanceof LivingEntity) || !((LivingEntity) entityIn).isElytraFlying()) {
entityIn.setMotion(entityIn.getMotion().mul(1.0D, 0.0D, 1.0D));
entityIn.onGround = true;
}
if (!(entityIn instanceof LivingEntity) || !((LivingEntity) entityIn).isElytraFlying()) {
entityIn.setMotion(entityIn.getMotion().mul(1.0D, 0.0D, 1.0D));
entityIn.setOnGround(true);
}
if (entityIn instanceof CreatureEntity) {
((CreatureEntity) entityIn).getNavigator().clearPath();
}
}
}
}

View File

@ -12,21 +12,21 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(TimeCommand.class)
public class TimeCommandMixin {
@Redirect(method = "addTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setDayTime(J)V"))
@Redirect(method = "addTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_241114_a_(J)V"))
private static void arclight$addTimeEvent(ServerWorld serverWorld, long time) {
TimeSkipEvent event = new TimeSkipEvent(((ServerWorldBridge) serverWorld).bridge$getWorld(), TimeSkipEvent.SkipReason.COMMAND, time - serverWorld.getDayTime());
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
serverWorld.setDayTime(serverWorld.getDayTime() + event.getSkipAmount());
serverWorld.func_241114_a_(serverWorld.getDayTime() + event.getSkipAmount());
}
}
@Redirect(method = "setTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setDayTime(J)V"))
@Redirect(method = "setTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_241114_a_(J)V"))
private static void arclight$setTimeEvent(ServerWorld serverWorld, long time) {
TimeSkipEvent event = new TimeSkipEvent(((ServerWorldBridge) serverWorld).bridge$getWorld(), TimeSkipEvent.SkipReason.COMMAND, time - serverWorld.getDayTime());
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
serverWorld.setDayTime(serverWorld.getDayTime() + event.getSkipAmount());
serverWorld.func_241114_a_(serverWorld.getDayTime() + event.getSkipAmount());
}
}
}

View File

@ -2,11 +2,11 @@ package io.izzel.arclight.common.mixin.core.entity.ai.goal;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.goal.TriggerSkeletonTrapGoal;
import net.minecraft.entity.monster.SkeletonEntity;
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.passive.horse.SkeletonHorseEntity;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.spongepowered.asm.mixin.Final;
@ -14,9 +14,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(TriggerSkeletonTrapGoal.class)
public class TriggerSkeletonTrapGoalMixin {
@ -25,23 +24,19 @@ public class TriggerSkeletonTrapGoalMixin {
@Shadow @Final private SkeletonHorseEntity horse;
// @formatter:on
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addLightningBolt(Lnet/minecraft/entity/effect/LightningBoltEntity;)V"))
public void arclight$thunder(CallbackInfo ci) {
((ServerWorldBridge) this.horse.world).bridge$pushStrikeLightningCause(LightningStrikeEvent.Cause.TRAP);
@Inject(method = "tick", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V"))
private void arclight$thunder(CallbackInfo ci) {
((WorldBridge) this.horse.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.TRAP);
}
@Inject(method = "createHorse", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public void arclight$addHorse(DifficultyInstance instance, CallbackInfoReturnable<AbstractHorseEntity> cir, SkeletonHorseEntity entity) {
((WorldBridge) entity.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.TRAP);
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private boolean arclight$addHorse(ServerWorld world, Entity entityIn) {
((ServerWorldBridge) world).bridge$strikeLightning((LightningBoltEntity) entityIn, LightningStrikeEvent.Cause.TRAP);
return true;
}
@Inject(method = "createSkeleton", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public void arclight$addSkeleton(DifficultyInstance difficulty, AbstractHorseEntity entity, CallbackInfoReturnable<SkeletonEntity> cir, SkeletonEntity skeletonEntity) {
if (((WorldBridge) skeletonEntity.getEntityWorld()).bridge$addEntity(skeletonEntity, CreatureSpawnEvent.SpawnReason.TRAP)) {
cir.setReturnValue(skeletonEntity);
} else {
cir.setReturnValue(null);
}
@Inject(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V"))
private void arclight$jockey(CallbackInfo ci) {
((WorldBridge) this.horse.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.JOCKEY);
}
}

View File

@ -9,6 +9,7 @@ import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.crafting.AbstractCookingRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.RecipeBookCategory;
import net.minecraft.tileentity.AbstractFurnaceTileEntity;
import net.minecraft.util.IIntArray;
import org.bukkit.craftbukkit.v.inventory.CraftInventoryFurnace;
@ -31,8 +32,8 @@ public abstract class AbstractFurnaceContainerMixin extends ContainerMixin {
private CraftInventoryView bukkitEntity = null;
private PlayerInventory playerInventory;
@Inject(method = "<init>(Lnet/minecraft/inventory/container/ContainerType;Lnet/minecraft/item/crafting/IRecipeType;ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/inventory/IInventory;Lnet/minecraft/util/IIntArray;)V", at = @At("RETURN"))
public void arclight$init(ContainerType<?> containerTypeIn, IRecipeType<? extends AbstractCookingRecipe> recipeTypeIn, int id, PlayerInventory playerInventoryIn, IInventory furnaceInventoryIn, IIntArray p_i50104_6_, CallbackInfo ci) {
@Inject(method = "<init>(Lnet/minecraft/inventory/container/ContainerType;Lnet/minecraft/item/crafting/IRecipeType;Lnet/minecraft/item/crafting/RecipeBookCategory;ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/inventory/IInventory;Lnet/minecraft/util/IIntArray;)V", at = @At("RETURN"))
public void arclight$init(ContainerType<?> p_i241922_1_, IRecipeType<? extends AbstractCookingRecipe> p_i241922_2_, RecipeBookCategory p_i241922_3_, int p_i241922_4_, PlayerInventory playerInventoryIn, IInventory p_i241922_6_, IIntArray p_i241922_7_, CallbackInfo ci) {
this.playerInventory = playerInventoryIn;
}

View File

@ -0,0 +1,29 @@
package io.izzel.arclight.common.mixin.core.inventory.container;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftResultInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.container.AbstractRepairContainer;
import net.minecraft.util.IWorldPosCallable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AbstractRepairContainer.class)
public abstract class AbstractRepairContainerMixin extends ContainerMixin {
// @formatter:off
@Shadow @Final protected IWorldPosCallable field_234644_e_;
@Shadow @Final protected IInventory field_234643_d_;
@Shadow @Final protected CraftResultInventory field_234642_c_;
@Shadow @Final protected PlayerEntity field_234645_f_;
// @formatter:on
@Inject(method = "canInteractWith", cancellable = true, at = @At("HEAD"))
private void arclight$unreachable(PlayerEntity playerIn, CallbackInfoReturnable<Boolean> cir) {
if (!bridge$isCheckReachable()) cir.setReturnValue(true);
}
}

View File

@ -68,9 +68,6 @@ public abstract class ContainerMixin implements ContainerBridge {
@Shadow public static boolean areItemsAndTagsEqual(ItemStack stack1, ItemStack stack2) { return false; }
// @formatter:on
@Shadow
protected abstract boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
public boolean checkReachable = true;
private InventoryView bukkitView;
@ -158,7 +155,7 @@ public abstract class ContainerMixin implements ContainerBridge {
* @reason
*/
@Overwrite
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) {
private ItemStack func_241440_b_(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) {
ItemStack itemstack = ItemStack.EMPTY;
PlayerInventory playerinventory = player.inventory;
if (clickTypeIn == ClickType.QUICK_CRAFT) {

View File

@ -16,6 +16,7 @@ import net.minecraft.inventory.container.EnchantmentContainer;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.stats.Stats;
import net.minecraft.util.IWorldPosCallable;
import net.minecraft.util.IntReferenceHolder;
@ -213,6 +214,12 @@ public abstract class EnchantmentContainerMixin extends ContainerMixin implement
if (flag) {
itemstack2 = new ItemStack(Items.ENCHANTED_BOOK);
CompoundNBT tag = itemstack2.getTag();
if (tag != null) {
itemstack2.setTag(tag.copy());
}
this.tableInventory.setInventorySlotContents(0, itemstack2);
}

View File

@ -4,15 +4,11 @@ import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
import io.izzel.arclight.common.bridge.util.IWorldPosCallableBridge;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.RepairContainer;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.IWorldPosCallable;
import net.minecraft.util.IntReferenceHolder;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.ForgeHooks;
@ -25,21 +21,13 @@ import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
@Mixin(RepairContainer.class)
public abstract class RepairContainerMixin extends ContainerMixin {
public abstract class RepairContainerMixin extends AbstractRepairContainerMixin {
// @formatter:off
@Shadow @Final private IWorldPosCallable worldPosCallable;
@Shadow @Final private IInventory inputSlots;
@Shadow @Final private IInventory outputSlot;
@Shadow @Final private PlayerEntity player;
@Shadow @Final public IntReferenceHolder maximumCost;
@Shadow public int materialCost;
@Shadow public String repairedItemName;
@ -47,19 +35,7 @@ public abstract class RepairContainerMixin extends ContainerMixin {
// @formatter:on
public int maximumRepairCost = 40;
private int lastLevelCost;
private CraftInventoryView bukkitEntity;
private PlayerInventory playerInventory;
@Inject(method = "<init>(ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/util/IWorldPosCallable;)V", at = @At("RETURN"))
public void arclight$init(int p_i50102_1_, PlayerInventory playerInventory, IWorldPosCallable p_i50102_3_, CallbackInfo ci) {
this.playerInventory = playerInventory;
}
@Inject(method = "canInteractWith", cancellable = true, at = @At("HEAD"))
public void arclight$unreachable(PlayerEntity playerIn, CallbackInfoReturnable<Boolean> cir) {
if (!bridge$isCheckReachable()) cir.setReturnValue(true);
}
/**
* @author IzzelAliz
@ -67,7 +43,7 @@ public abstract class RepairContainerMixin extends ContainerMixin {
*/
@Overwrite
public void updateRepairOutput() {
ItemStack itemstack = this.inputSlots.getStackInSlot(0);
ItemStack itemstack = this.field_234643_d_.getStackInSlot(0);
this.maximumCost.set(1);
int i = 0;
int j = 0;
@ -78,14 +54,14 @@ public abstract class RepairContainerMixin extends ContainerMixin {
this.maximumCost.set(0);
} else {
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = this.inputSlots.getStackInSlot(1);
ItemStack itemstack2 = this.field_234643_d_.getStackInSlot(1);
Map<Enchantment, Integer> map = EnchantmentHelper.getEnchantments(itemstack1);
j = j + itemstack.getRepairCost() + (itemstack2.isEmpty() ? 0 : itemstack2.getRepairCost());
this.materialCost = 0;
boolean flag = false;
if (!itemstack2.isEmpty()) {
if (!ForgeHooks.onAnvilChange((RepairContainer) (Object) this, itemstack, itemstack2, outputSlot, repairedItemName, j))
if (!ForgeHooks.onAnvilChange((RepairContainer) (Object) this, itemstack, itemstack2, field_234642_c_, repairedItemName, j))
return;
flag = itemstack2.getItem() == Items.ENCHANTED_BOOK && !EnchantedBookItem.getEnchantments(itemstack2).isEmpty();
if (itemstack1.isDamageable() && itemstack1.getItem().getIsRepairable(itemstack, itemstack2)) {
@ -136,11 +112,11 @@ public abstract class RepairContainerMixin extends ContainerMixin {
for (Enchantment enchantment1 : map1.keySet()) {
if (enchantment1 != null) {
int i2 = map.containsKey(enchantment1) ? map.get(enchantment1) : 0;
int i2 = map.getOrDefault(enchantment1, 0);
int j2 = map1.get(enchantment1);
j2 = i2 == j2 ? j2 + 1 : Math.max(j2, i2);
boolean flag1 = enchantment1.canApply(itemstack);
if (this.player.abilities.isCreativeMode || itemstack.getItem() == Items.ENCHANTED_BOOK) {
if (this.field_234645_f_.abilities.isCreativeMode || itemstack.getItem() == Items.ENCHANTED_BOOK) {
flag1 = true;
}
@ -218,7 +194,7 @@ public abstract class RepairContainerMixin extends ContainerMixin {
this.maximumCost.set(maximumRepairCost - 1);
}
if (this.maximumCost.get() >= maximumRepairCost && !this.player.abilities.isCreativeMode) {
if (this.maximumCost.get() >= maximumRepairCost && !this.field_234645_f_.abilities.isCreativeMode) {
itemstack1 = ItemStack.EMPTY;
}
@ -249,8 +225,8 @@ public abstract class RepairContainerMixin extends ContainerMixin {
}
CraftInventory inventory = new CraftInventoryAnvil(
((IWorldPosCallableBridge) this.worldPosCallable).bridge$getLocation(), this.inputSlots, this.outputSlot, (RepairContainer) (Object) this);
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
((IWorldPosCallableBridge) this.field_234644_e_).bridge$getLocation(), this.field_234643_d_, this.field_234642_c_, (RepairContainer) (Object) this);
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.field_234645_f_).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
return bukkitEntity;
}
}

View File

@ -0,0 +1,33 @@
package io.izzel.arclight.common.mixin.core.inventory.container;
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
import net.minecraft.inventory.CraftResultInventory;
import net.minecraft.inventory.container.SmithingTableContainer;
import net.minecraft.item.ItemStack;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.inventory.CraftInventory;
import org.bukkit.craftbukkit.v.inventory.CraftInventorySmithing;
import org.bukkit.craftbukkit.v.inventory.CraftInventoryView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(SmithingTableContainer.class)
public abstract class SmithingTableContainerMixin extends AbstractRepairContainerMixin {
private CraftInventoryView bukkitEntity;
@Redirect(method = "updateRepairOutput", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/CraftResultInventory;setInventorySlotContents(ILnet/minecraft/item/ItemStack;)V"))
private void arclight$prepareSmithing(CraftResultInventory craftResultInventory, int index, ItemStack stack) {
CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), stack);
}
@Override
public CraftInventoryView getBukkitView() {
if (this.bukkitEntity != null) {
return this.bukkitEntity;
}
CraftInventory inventory = new CraftInventorySmithing(this.field_234643_d_, this.field_234642_c_);
return this.bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.field_234645_f_).bridge$getBukkitEntity(), inventory, (SmithingTableContainer) (Object) this);
}
}

View File

@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.item.crafting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import io.izzel.arclight.common.bridge.inventory.IInventoryBridge;
@ -13,6 +14,7 @@ import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.RecipeManager;
import net.minecraft.profiler.IProfiler;
import net.minecraft.resources.IResourceManager;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.registry.Registry;
@ -45,7 +47,7 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge {
*/
@Overwrite
@SuppressWarnings("unchecked")
protected void apply(Map<ResourceLocation, JsonObject> splashList, IResourceManager resourceManagerIn, IProfiler profilerIn) {
protected void apply(Map<ResourceLocation, JsonElement> objectIn, IResourceManager resourceManagerIn, IProfiler profilerIn) {
this.someRecipesErrored = false;
Map<IRecipeType<?>, Object2ObjectLinkedOpenHashMap<ResourceLocation, IRecipe<?>>> map = Maps.newHashMap();
@ -53,17 +55,17 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge {
map.put(type, new Object2ObjectLinkedOpenHashMap<>());
}
for (Map.Entry<ResourceLocation, JsonObject> entry : splashList.entrySet()) {
for (Map.Entry<ResourceLocation, JsonElement> entry : objectIn.entrySet()) {
ResourceLocation resourcelocation = entry.getKey();
if (resourcelocation.getPath().startsWith("_"))
continue; //Forge: filter anything beginning with "_" as it's used for metadata.
try {
if (!CraftingHelper.processConditions(entry.getValue(), "conditions")) {
if (entry.getValue().isJsonObject() && !CraftingHelper.processConditions(entry.getValue().getAsJsonObject(), "conditions")) {
LOGGER.info("Skipping loading recipe {} as it's conditions were not met", resourcelocation);
continue;
}
IRecipe<?> irecipe = deserializeRecipe(resourcelocation, entry.getValue());
IRecipe<?> irecipe = deserializeRecipe(resourcelocation, JSONUtils.getJsonObject(entry.getValue(), "top element"));
if (irecipe == null) {
LOGGER.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation);
continue;

View File

@ -137,14 +137,14 @@ public abstract class PlayerListMixin implements PlayerListBridge {
cserver = new CraftServer((DedicatedServer) minecraftServer, (PlayerList) (Object) this);
((MinecraftServerBridge) minecraftServer).bridge$setServer(cserver);
((MinecraftServerBridge) minecraftServer).bridge$setConsole(ColouredConsoleSender.getInstance());
org.spigotmc.SpigotConfig.init(new File("./spigot.yml"));
org.spigotmc.SpigotConfig.registerCommands();
} catch (Throwable t) {
t.printStackTrace();
}
try {
ArclightMod.LOGGER.info("registry.begin");
BukkitRegistry.registerAll();
org.spigotmc.SpigotConfig.init(new File("./spigot.yml"));
org.spigotmc.SpigotConfig.registerCommands();
} catch (Throwable t) {
ArclightMod.LOGGER.error("registry.error", t);
}

View File

@ -11,6 +11,8 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.tileentity.AbstractFurnaceTileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
@ -43,7 +45,7 @@ public abstract class AbstractFurnaceTileEntityMixin extends LockableTileEntityM
@Shadow protected abstract boolean isBurning();
@Shadow protected abstract boolean canSmelt(@Nullable IRecipe<?> recipeIn);
@Shadow public abstract void setRecipeUsed(@Nullable IRecipe<?> recipe);
@Shadow public abstract void func_213995_d(PlayerEntity p_213995_1_);
@Shadow public abstract List<IRecipe<?>> grantStoredRecipeExperience(World world, Vector3d pos);
// @formatter:on
public List<HumanEntity> transaction = new ArrayList<>();
@ -122,22 +124,28 @@ public abstract class AbstractFurnaceTileEntityMixin extends LockableTileEntityM
}
private static AbstractFurnaceTileEntity arclight$captureFurnace;
private static PlayerEntity arclight$capturePlayer;
private static ItemStack arclight$item;
private static int arclight$captureAmount;
public void d(PlayerEntity entity, ItemStack itemStack, int amount) {
arclight$item = itemStack;
arclight$captureAmount = amount;
arclight$captureFurnace = (AbstractFurnaceTileEntity) (Object) this;
this.func_213995_d(entity);
arclight$item = null;
arclight$captureAmount = 0;
arclight$captureFurnace = null;
public List<IRecipe<?>> a(World world, Vector3d pos, PlayerEntity entity, ItemStack itemStack, int amount) {
try {
arclight$item = itemStack;
arclight$captureAmount = amount;
arclight$captureFurnace = (AbstractFurnaceTileEntity) (Object) this;
arclight$capturePlayer = entity;
return this.grantStoredRecipeExperience(world, pos);
} finally {
arclight$item = null;
arclight$captureAmount = 0;
arclight$captureFurnace = null;
arclight$capturePlayer = null;
}
}
@Override
public void bridge$dropExp(PlayerEntity entity, ItemStack itemStack, int amount) {
d(entity, itemStack, amount);
public List<IRecipe<?>> bridge$dropExp(World world, Vector3d pos, PlayerEntity entity, ItemStack itemStack, int amount) {
return a(world, pos, entity, itemStack, amount);
}
/**
@ -145,29 +153,25 @@ public abstract class AbstractFurnaceTileEntityMixin extends LockableTileEntityM
* @reason
*/
@Overwrite
private static void spawnExpOrbs(PlayerEntity entity, int ex, float f) {
if (f == 0.0F) {
ex = 0;
} else if (f < 1.0F) {
int i = MathHelper.floor((float) ex * f);
if (i < MathHelper.ceil((float) ex * f) && Math.random() < (double) ((float) ex * f - (float) i)) {
++i;
}
ex = i;
private static void splitAndSpawnExperience(World world, Vector3d pos, int craftedAmount, float experience) {
int i = MathHelper.floor((float) craftedAmount * experience);
float f = MathHelper.frac((float) craftedAmount * experience);
if (f != 0.0F && Math.random() < (double) f) {
++i;
}
if (arclight$captureFurnace != null && arclight$captureAmount != 0) {
FurnaceExtractEvent event = new FurnaceExtractEvent(((ServerPlayerEntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(arclight$captureFurnace.getWorld(), arclight$captureFurnace.getPos()), CraftMagicNumbers.getMaterial(arclight$item.getItem()), arclight$captureAmount, ex);
if (arclight$capturePlayer != null && arclight$captureAmount != 0) {
FurnaceExtractEvent event = new FurnaceExtractEvent(((ServerPlayerEntityBridge) arclight$capturePlayer).bridge$getBukkitEntity(),
CraftBlock.at(world, arclight$captureFurnace.getPos()), CraftMagicNumbers.getMaterial(arclight$item.getItem()), arclight$captureAmount, i);
Bukkit.getPluginManager().callEvent(event);
ex = event.getExpToDrop();
}
while (ex > 0) {
int j = ExperienceOrbEntity.getXPSplit(ex);
ex -= j;
entity.world.addEntity(new ExperienceOrbEntity(entity.world, entity.posX, entity.posY + 0.5D, entity.posZ + 0.5D, j));
i = event.getExpToDrop();
}
while (i > 0) {
int j = ExperienceOrbEntity.getXPSplit(i);
i -= j;
world.addEntity(new ExperienceOrbEntity(world, pos.x, pos.y, pos.z, j));
}
}
@Override

View File

@ -2,10 +2,12 @@ package io.izzel.arclight.common.mixin.core.tileentity;
import com.google.common.collect.Lists;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.BeeEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tags.EntityTypeTags;
@ -15,6 +17,7 @@ import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityEnterBlockEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -33,7 +36,7 @@ public abstract class BeehiveTileEntityMixin extends TileEntityMixin {
// @formatter:off
@Shadow @Final private List<BeehiveTileEntity.Bee> bees;
@Shadow protected abstract boolean releaseBee(BlockState p_226967_1_, CompoundNBT p_226967_2_, @Nullable List<Entity> p_226967_3_, BeehiveTileEntity.State p_226967_4_);
@Shadow protected abstract boolean func_235651_a_(BlockState p_235651_1_, BeehiveTileEntity.Bee p_235651_2_, @org.jetbrains.annotations.Nullable List<Entity> p_235651_3_, BeehiveTileEntity.State p_235651_4_);
// @formatter:on
public int maxBees = 3;
@ -47,9 +50,15 @@ public abstract class BeehiveTileEntityMixin extends TileEntityMixin {
return this.bees.size() >= maxBees;
}
@Redirect(method = "angerBees", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/BeeEntity;setAttackTarget(Lnet/minecraft/entity/LivingEntity;)V"))
private void arclight$angryReason(BeeEntity beeEntity, LivingEntity livingEntity) {
((MobEntityBridge) beeEntity).bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true);
beeEntity.setAttackTarget(livingEntity);
}
public List<Entity> tryReleaseBee(BlockState blockState, BeehiveTileEntity.State state, boolean force) {
List<Entity> list = Lists.newArrayList();
this.bees.removeIf(bee -> this.releaseBee(blockState, bee.entityData, list, state, force));
this.bees.removeIf(bee -> this.releaseBee(blockState, bee, list, state, force));
return list;
}
@ -67,10 +76,10 @@ public abstract class BeehiveTileEntityMixin extends TileEntityMixin {
}
}
private boolean releaseBee(BlockState blockState, CompoundNBT nbt, @Nullable List<Entity> list, BeehiveTileEntity.State state, boolean force) {
private boolean releaseBee(BlockState blockState, BeehiveTileEntity.Bee bee, @Nullable List<Entity> list, BeehiveTileEntity.State state, boolean force) {
arclight$force = force;
try {
return this.releaseBee(blockState, nbt, list, state);
return this.func_235651_a_(blockState, bee, list, state);
} finally {
arclight$force = false;
}
@ -78,12 +87,12 @@ public abstract class BeehiveTileEntityMixin extends TileEntityMixin {
private transient boolean arclight$force;
@Redirect(method = "releaseBee", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isNightTime()Z"))
@Redirect(method = "func_235651_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isNightTime()Z"))
private boolean arclight$bypassNightCheck(World world) {
return !arclight$force && world.isNightTime();
}
@Redirect(method = "releaseBee", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getType()Lnet/minecraft/entity/EntityType;"))
@Redirect(method = "func_235651_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getType()Lnet/minecraft/entity/EntityType;"))
private EntityType<?> arclight$spawnFirst(Entity entity) {
EntityType<?> type = entity.getType();
if (type.isContained(EntityTypeTags.BEEHIVE_INHABITORS)) {
@ -97,13 +106,13 @@ public abstract class BeehiveTileEntityMixin extends TileEntityMixin {
return type;
}
@Redirect(method = "releaseBee", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
@Redirect(method = "func_235651_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private boolean arclight$addedBefore(World world, Entity entityIn) {
return true;
}
@Inject(method = "read", at = @At("RETURN"))
private void arclight$readMax(CompoundNBT compound, CallbackInfo ci) {
private void arclight$readMax(BlockState state, CompoundNBT compound, CallbackInfo ci) {
if (compound.contains("Bukkit.MaxEntities")) {
this.maxBees = compound.getInt("Bukkit.MaxEntities");
}

View File

@ -1,12 +1,15 @@
package io.izzel.arclight.common.mixin.core.tileentity;
import io.izzel.arclight.common.bridge.inventory.IInventoryBridge;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.ChestTileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.HumanEntity;
@ -15,6 +18,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
@ -25,11 +29,12 @@ public abstract class ChestTileEntityMixin extends LockableTileEntityMixin {
// @formatter:off
@Shadow private NonNullList<ItemStack> chestContents;
@Shadow protected int numPlayersUsing;
@Shadow public int numPlayersUsing;
// @formatter:on
public List<HumanEntity> transaction = new ArrayList<>();
private int maxStack = IInventoryBridge.MAX_STACK;
public boolean opened;
@Inject(method = "openInventory", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/ChestTileEntity;onOpenOrClose()V"))
public void arclight$openRedstone(PlayerEntity player, CallbackInfo ci) {
@ -59,6 +64,19 @@ public abstract class ChestTileEntityMixin extends LockableTileEntityMixin {
}
}
@Inject(method = "tick", cancellable = true, at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/tileentity/ChestTileEntity;prevLidAngle:F"))
private void arclight$openByApi(CallbackInfo ci) {
if (opened) {
this.numPlayersUsing--;
ci.cancel();
}
}
@Redirect(method = "onOpenOrClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V"))
private void arclight$soundIfByPlayer(World world, BlockPos pos, Block blockIn, int eventID, int eventParam) {
if (!opened) world.addBlockEvent(pos, blockIn, eventID, eventParam);
}
@Override
public List<ItemStack> getContents() {
return this.chestContents;
@ -94,6 +112,7 @@ public abstract class ChestTileEntityMixin extends LockableTileEntityMixin {
this.maxStack = size;
}
@Override
public boolean onlyOpsCanSetNbt() {
return true;
}

View File

@ -15,12 +15,13 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.LecternTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIntArray;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v.command.CraftBlockCommandSender;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -29,6 +30,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import javax.annotation.Nullable;
import java.util.UUID;
@Mixin(LecternTileEntity.class)
public abstract class LecternTileEntityMixin extends TileEntityMixin implements ICommandSource, ICommandSourceBridge {
@ -39,7 +41,7 @@ public abstract class LecternTileEntityMixin extends TileEntityMixin implements
// @formatter:on
@Redirect(method = "createCommandSource", at = @At(value = "NEW", target = "net/minecraft/command/CommandSource"))
private CommandSource arclight$source(ICommandSource source, Vec3d vec3d, Vec2f vec2f, ServerWorld world, int i, String s, ITextComponent component, MinecraftServer server, @Nullable Entity entity) {
private CommandSource arclight$source(ICommandSource source, Vector3d vec3d, Vector2f vec2f, ServerWorld world, int i, String s, ITextComponent component, MinecraftServer server, @Nullable Entity entity) {
return new CommandSource(this, vec3d, vec2f, world, i, s, component, server, entity);
}
@ -55,7 +57,7 @@ public abstract class LecternTileEntityMixin extends TileEntityMixin implements
}
@Override
public void sendMessage(ITextComponent component) {
public void sendMessage(@NotNull ITextComponent component, @NotNull UUID uuid) {
}
@Override

View File

@ -1,5 +1,6 @@
package io.izzel.arclight.common.mixin.core.tileentity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.ShulkerBoxTileEntity;
import net.minecraft.util.NonNullList;
@ -8,6 +9,9 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
import java.util.List;
@ -21,6 +25,17 @@ public abstract class ShulkerBoxTileEntityMixin extends LockableTileEntityMixin
public List<HumanEntity> transaction = new ArrayList<>();
private int maxStack = MAX_STACK;
public boolean opened;
@Inject(method = "openInventory", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V"))
private void arclight$sound1(PlayerEntity player, CallbackInfo ci) {
if (opened) ci.cancel();
}
@Inject(method = "closeInventory", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V"))
private void arclight$sound2(PlayerEntity player, CallbackInfo ci) {
if (opened) ci.cancel();
}
@Override
public List<ItemStack> getContents() {

View File

@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.tileentity;
import io.izzel.arclight.common.bridge.command.ICommandSourceBridge;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.tileentity.SignTileEntityBridge;
import net.minecraft.command.CommandSource;
import net.minecraft.command.ICommandSource;
import net.minecraft.entity.Entity;
@ -9,21 +10,22 @@ import net.minecraft.item.DyeColor;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.SignTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v.command.CraftBlockCommandSender;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import io.izzel.arclight.common.bridge.tileentity.SignTileEntityBridge;
import javax.annotation.Nullable;
import java.util.UUID;
@Mixin(SignTileEntity.class)
public abstract class SignTileEntityMixin extends TileEntityMixin implements SignTileEntityBridge, ICommandSource, ICommandSourceBridge {
@ -33,7 +35,7 @@ public abstract class SignTileEntityMixin extends TileEntityMixin implements Sig
// @formatter:on
@Redirect(method = "getCommandSource", at = @At(value = "NEW", target = "net/minecraft/command/CommandSource"))
private CommandSource arclight$source(ICommandSource source, Vec3d vec3d, Vec2f vec2f, ServerWorld world, int i, String s, ITextComponent component, MinecraftServer server, @Nullable Entity entity) {
private CommandSource arclight$source(ICommandSource source, Vector3d vec3d, Vector2f vec2f, ServerWorld world, int i, String s, ITextComponent component, MinecraftServer server, @Nullable Entity entity) {
return new CommandSource(this, vec3d, vec2f, world, i, s, component, server, entity);
}
@ -45,7 +47,7 @@ public abstract class SignTileEntityMixin extends TileEntityMixin implements Sig
}
@Override
public void sendMessage(ITextComponent component) {
public void sendMessage(@NotNull ITextComponent component, @NotNull UUID uuid) {
}
@Override

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.tileentity;
import io.izzel.arclight.common.bridge.tileentity.TileEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
@ -26,15 +27,16 @@ public abstract class TileEntityMixin implements TileEntityBridge {
public CraftPersistentDataContainer persistentDataContainer;
// @formatter:off
@Shadow @Nullable protected World world;
@Shadow @Nullable public World world;
@Shadow protected BlockPos pos;
@Shadow public abstract BlockState getBlockState();
@Shadow public abstract void markDirty();
@Shadow public abstract BlockPos getPos();
@Shadow public BlockPos getPos() { return null; }
@Shadow public abstract boolean onlyOpsCanSetNbt();
// @formatter:on
@Inject(method = "read", at = @At("RETURN"))
public void arclight$loadPersistent(CompoundNBT compound, CallbackInfo ci) {
public void arclight$loadPersistent(BlockState state, CompoundNBT compound, CallbackInfo ci) {
this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
CompoundNBT persistentDataTag = compound.getCompound("PublicBukkitValues");
@ -54,7 +56,7 @@ public abstract class TileEntityMixin implements TileEntityBridge {
if (this.world == null) return null;
org.bukkit.block.Block block = CraftBlock.at(this.world, this.pos);
if (block == null) {
org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "No block for owner at %s %d %d %d", new Object[]{world.getWorld(), pos.getX(), pos.getY(), pos.getZ()});
org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "No block for owner at %s %d %d %d", new Object[]{((WorldBridge) world).bridge$getWorld(), pos.getX(), pos.getY(), pos.getZ()});
return null;
}
org.bukkit.block.BlockState state = block.getState();

View File

@ -0,0 +1,38 @@
package io.izzel.arclight.common.mixin.core.util.text;
import net.minecraft.util.text.Color;
import net.minecraft.util.text.TextFormatting;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
@Mixin(Color.class)
public class ColorMixin {
// @formatter:off
@Shadow @Final @Mutable @Nullable public String field_240741_d_;
// @formatter:on
public TextFormatting format;
public void arclight$constructor(int p_i232573_1_) {
throw new RuntimeException();
}
public void arclight$constructor(int p_i232573_1_, String p_i232573_2_, TextFormatting textFormatting) {
arclight$constructor(p_i232573_1_);
this.field_240741_d_ = p_i232573_2_;
this.format = textFormatting;
}
@Inject(method = "<init>(ILjava/lang/String;)V", at = @At("RETURN"))
private void arclight$withFormat(int p_i232573_1_, String name, CallbackInfo ci) {
this.format = TextFormatting.getValueByName(name);
}
}

View File

@ -0,0 +1,41 @@
package io.izzel.arclight.common.mixin.core.util.text;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.Color;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import javax.annotation.Nullable;
@Mixin(Style.class)
public class StyleMixin {
// @formatter:off
@Shadow @Final @Nullable private Color color;
@Shadow @Final @Nullable private Boolean bold;
@Shadow @Final @Nullable private Boolean italic;
@Shadow @Final @Nullable private Boolean underlined;
@Shadow @Final @Nullable private Boolean strikethrough;
@Shadow @Final @Nullable private Boolean obfuscated;
@Shadow @Final @Nullable private ClickEvent clickEvent;
@Shadow @Final @Nullable private HoverEvent hoverEvent;
@Shadow @Final @Nullable private String insertion;
@Shadow @Final @Nullable private ResourceLocation fontId;
// @formatter:on
public Style setStrikethrough(final Boolean b) {
return new Style(this.color, this.bold, this.italic, this.underlined, b, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.fontId);
}
public Style setUnderline(final Boolean b) {
return new Style(this.color, this.bold, this.italic, b, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.fontId);
}
public Style setRandom(final Boolean b) {
return new Style(this.color, this.bold, this.italic, this.underlined, this.strikethrough, b, this.clickEvent, this.hoverEvent, this.insertion, this.fontId);
}
}

View File

@ -1,13 +1,20 @@
package io.izzel.arclight.common.mixin.core.world;
import io.izzel.arclight.common.bridge.world.IWorldBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.Entity;
import net.minecraft.world.IServerWorld;
import net.minecraft.world.IWorld;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Iterator;
@Mixin(IServerWorld.class)
public interface IServerWorldMixin extends IWorldBridge {
public interface IServerWorldMixin extends IWorld, IWorldBridge, WorldBridge {
// @formatter:off
@Shadow ServerWorld getWorld();
@ -17,4 +24,19 @@ public interface IServerWorldMixin extends IWorldBridge {
default ServerWorld bridge$getMinecraftWorld() {
return this.getWorld();
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
default void func_242417_l(Entity entity) {
CreatureSpawnEvent.SpawnReason spawnReason = bridge$getAddEntityReason();
Iterator<Entity> iterator = entity.getSelfAndPassengers().iterator();
while (iterator.hasNext()) {
Entity next = iterator.next();
bridge$pushAddEntityReason(spawnReason);
this.addEntity(next);
}
}
}

View File

@ -14,6 +14,7 @@ import net.minecraft.world.biome.BiomeContainer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.CraftChunk;
import org.bukkit.event.world.ChunkLoadEvent;
@ -45,10 +46,12 @@ public abstract class ChunkMixin implements ChunkBridge {
public boolean mustNotSave;
public boolean needsDecoration;
private transient boolean arclight$doPlace;
public ServerWorld $$world;
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/world/biome/BiomeContainer;Lnet/minecraft/util/palette/UpgradeData;Lnet/minecraft/world/ITickList;Lnet/minecraft/world/ITickList;J[Lnet/minecraft/world/chunk/ChunkSection;Ljava/util/function/Consumer;)V", at = @At("RETURN"))
private void arclight$init(World worldIn, ChunkPos chunkPosIn, BiomeContainer biomeContainerIn, UpgradeData upgradeDataIn, ITickList<Block> tickBlocksIn, ITickList<Fluid> tickFluidsIn, long inhabitedTimeIn, ChunkSection[] sectionsIn, Consumer<Chunk> postLoadConsumerIn, CallbackInfo ci) {
bridge$setBukkitChunk(new CraftChunk((Chunk) (Object) this));
this.$$world = ((ServerWorld) world);
}
public org.bukkit.Chunk getBukkitChunk() {
@ -117,10 +120,10 @@ public abstract class ChunkMixin implements ChunkBridge {
if (this.needsDecoration) {
this.needsDecoration = false;
java.util.Random random = new java.util.Random();
random.setSeed(world.getSeed());
random.setSeed(((ServerWorld) world).getSeed());
long xRand = random.nextLong() / 2L * 2L + 1L;
long zRand = random.nextLong() / 2L * 2L + 1L;
random.setSeed((long) this.pos.x * xRand + (long) this.pos.z * zRand ^ world.getSeed());
random.setSeed((long) this.pos.x * xRand + (long) this.pos.z * zRand ^ ((ServerWorld) world).getSeed());
org.bukkit.World world = ((WorldBridge) this.world).bridge$getWorld();
if (world != null) {

View File

@ -6,17 +6,12 @@ import io.izzel.arclight.common.bridge.world.server.ChunkHolderBridge;
import io.izzel.arclight.common.bridge.world.server.ChunkManagerBridge;
import io.izzel.arclight.common.bridge.world.server.ServerChunkProviderBridge;
import io.izzel.arclight.common.bridge.world.server.TicketManagerBridge;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.entity.EntityClassification;
import net.minecraft.profiler.IProfiler;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.WorldType;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.server.ChunkHolder;
import net.minecraft.world.server.ChunkManager;
import net.minecraft.world.server.ServerChunkProvider;
@ -24,8 +19,7 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.server.ServerWorldLightManager;
import net.minecraft.world.server.TicketManager;
import net.minecraft.world.server.TicketType;
import net.minecraft.world.spawner.WorldEntitySpawner;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.world.storage.IWorldInfo;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -37,8 +31,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
@Mixin(ServerChunkProvider.class)
public abstract class ServerChunkProviderMixin implements ServerChunkProviderBridge {
@ -53,11 +47,9 @@ public abstract class ServerChunkProviderMixin implements ServerChunkProviderBri
@Shadow @Nullable protected abstract ChunkHolder func_217213_a(long chunkPosIn);
@Shadow protected abstract boolean func_217235_l();
@Shadow protected abstract boolean func_217224_a(@Nullable ChunkHolder chunkHolderIn, int p_217224_2_);
@Shadow private long lastGameTime;
@Shadow public boolean spawnHostiles;
@Shadow public boolean spawnPassives;
@Shadow @Final private static int field_217238_b;
@Shadow @Final public ChunkGenerator<?> generator;
@Shadow protected abstract void func_241098_a_(long p_241098_1_, Consumer<Chunk> p_241098_3_);
@Invoker("func_217235_l") public abstract boolean bridge$tickDistanceManager();
@Accessor("lightManager") public abstract ServerWorldLightManager bridge$getLightManager();
// @formatter:on
@ -105,98 +97,16 @@ public abstract class ServerChunkProviderMixin implements ServerChunkProviderBri
return this.func_217224_a(chunkholder, j) ? ChunkHolder.MISSING_CHUNK_FUTURE : chunkholder.func_219276_a(requiredStatus, this.chunkManager);
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private void tickChunks() {
long i = this.world.getGameTime();
long j = i - this.lastGameTime;
this.lastGameTime = i;
WorldInfo worldinfo = this.world.getWorldInfo();
boolean flag = worldinfo.getGenerator() == WorldType.DEBUG_ALL_BLOCK_STATES;
boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !this.world.getPlayers().isEmpty();
if (!flag) {
this.world.getProfiler().startSection("pollingChunks");
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
BlockPos blockpos = this.world.getSpawnPoint();
@Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getBoolean(Lnet/minecraft/world/GameRules$RuleKey;)Z"))
private boolean arclight$noPlayer(GameRules gameRules, GameRules.RuleKey<GameRules.BooleanValue> key) {
return gameRules.getBoolean(key) && !this.world.getPlayers().isEmpty();
}
boolean spawnAnimal = ((WorldBridge) this.world).bridge$ticksPerAnimalSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerAnimalSpawns() == 0;
boolean spawnMonster = ((WorldBridge) this.world).bridge$ticksPerMonsterSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerMonsterSpawns() == 0;
boolean spawnWater = ((WorldBridge) this.world).bridge$ticksPerWaterSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerWaterSpawns() == 0;
boolean spawnAmbient = ((WorldBridge) this.world).bridge$ticksPerAmbientSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerAmbientSpawns() == 0;
boolean flag2 = spawnAnimal;
this.world.getProfiler().startSection("naturalSpawnCount");
int l = this.ticketManager.getSpawningChunksCount();
EntityClassification[] aentityclassification = EntityClassification.values();
Object2IntMap<EntityClassification> object2intmap = this.world.countEntities();
this.world.getProfiler().endSection();
((ChunkManagerBridge) this.chunkManager).bridge$getLoadedChunksIterable().forEach((p_223434_10_) -> {
Optional<Chunk> optional = p_223434_10_.getEntityTickingFuture().getNow(ChunkHolder.UNLOADED_CHUNK).left();
if (optional.isPresent()) {
Chunk chunk = optional.get();
this.world.getProfiler().startSection("broadcast");
p_223434_10_.sendChanges(chunk);
this.world.getProfiler().endSection();
ChunkPos chunkpos = p_223434_10_.getPosition();
if (!((ChunkManagerBridge) this.chunkManager).bridge$isOutsideSpawningRadius(chunkpos)) {
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
if (flag1 && (this.spawnHostiles || this.spawnPassives) && this.world.getWorldBorder().contains(chunk.getPos())) {
this.world.getProfiler().startSection("spawner");
for (EntityClassification entityclassification : aentityclassification) {
boolean spawnThisTick = true;
int limit = entityclassification.getMaxNumberOfCreature();
switch (entityclassification) {
case MONSTER:
spawnThisTick = spawnMonster;
limit = ((WorldBridge) world).bridge$getWorld().getMonsterSpawnLimit();
break;
case CREATURE:
spawnThisTick = spawnAnimal;
limit = ((WorldBridge) world).bridge$getWorld().getAnimalSpawnLimit();
break;
case WATER_CREATURE:
spawnThisTick = spawnWater;
limit = ((WorldBridge) world).bridge$getWorld().getWaterAnimalSpawnLimit();
break;
case AMBIENT:
spawnThisTick = spawnAmbient;
limit = ((WorldBridge) world).bridge$getWorld().getAmbientSpawnLimit();
break;
}
if (!spawnThisTick || limit == 0) {
continue;
}
if (entityclassification != EntityClassification.MISC && (!entityclassification.getPeacefulCreature() || this.spawnPassives) && (entityclassification.getPeacefulCreature() || this.spawnHostiles) && (!entityclassification.getAnimal() || flag2)) {
int i1 = limit * l / field_217238_b;
if (object2intmap.getInt(entityclassification) <= i1) {
WorldEntitySpawner.spawnEntitiesInChunk(entityclassification, this.world, chunk, blockpos);
}
}
}
this.world.getProfiler().endSection();
}
this.world.tickEnvironment(chunk, k);
}
}
});
this.world.getProfiler().startSection("customSpawners");
if (flag1) {
this.generator.spawnMobs(this.world, this.spawnHostiles, this.spawnPassives);
}
this.world.getProfiler().endSection();
this.world.getProfiler().endSection();
}
((ChunkManagerBridge) this.chunkManager).bridge$tickEntityTracker();
@Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/IWorldInfo;getGameTime()J"))
private long arclight$ticksPer(IWorldInfo worldInfo) {
long gameTime = worldInfo.getGameTime();
long ticksPer = ((WorldBridge) this.world).bridge$ticksPerAnimalSpawns();
return (ticksPer != 0L && gameTime % ticksPer == 0) ? 0 : 1;
}
public void close(boolean save) throws IOException {

View File

@ -269,6 +269,11 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
this.arclight$reason = reason;
}
@Override
public CreatureSpawnEvent.SpawnReason bridge$getAddEntityReason() {
return this.arclight$reason;
}
public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
bridge$pushAddEntityReason(reason);
return addEntity(entity);

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.core.world.storage;
import io.izzel.arclight.common.bridge.world.storage.SaveFormatBridge;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.Dimension;
import net.minecraft.world.storage.SaveFormat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.io.IOException;
@Mixin(SaveFormat.class)
public abstract class SaveFormatMixin implements SaveFormatBridge {
// @formatter:off
@Shadow public abstract SaveFormat.LevelSave getLevelSave(String saveName) throws IOException;
// @formatter:on
public SaveFormat.LevelSave getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException {
return getLevelSave(saveName);
}
// mock
public SaveFormat.LevelSave c(String saveName, RegistryKey<Dimension> world) throws IOException {
return getLevelSave(saveName, world);
}
@Override
public SaveFormat.LevelSave bridge$getLevelSave(String saveName, RegistryKey<Dimension> world) throws IOException {
return getLevelSave(saveName, world);
}
}

View File

@ -92,6 +92,13 @@ public class ArclightMixinPlugin implements IMixinConfigPlugin {
new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "b", "(Lcom/mojang/authlib/GameProfile;Lcom/google/common/base/Predicate;Z)Ljava/util/concurrent/Future;", null, null)
)
))
.put("net.minecraft.command.impl.ReloadCommand",
Maps.immutableEntry(
ImmutableList.of(),
ImmutableList.of(
new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "reload", "(Lnet/minecraft/server/MinecraftServer;)V", null, null)
)
))
.build();
private final Set<String> modifyConstructor = ImmutableSet.<String>builder()
@ -111,6 +118,7 @@ public class ArclightMixinPlugin implements IMixinConfigPlugin {
.add("net.minecraft.util.math.shapes.IndirectMerger")
.add("net.minecraft.network.play.client.CCloseWindowPacket")
.add("net.minecraft.world.dimension.DimensionType")
.add("net.minecraft.util.text.Color")
.build();
@Override
@ -187,6 +195,25 @@ public class ArclightMixinPlugin implements IMixinConfigPlugin {
FieldNode node = new FieldNode(Opcodes.ACC_PUBLIC, "field_190539_a", "Lnet/minecraft/entity/passive/horse/LlamaEntity;", null, null);
targetClass.fields.add(node);
}
if (targetClassName.equals("net.minecraft.world.chunk.Chunk")) {
for (FieldNode field : targetClass.fields) {
if (field.name.equals("$$world")) {
field.name = "world";
}
}
for (MethodNode method : targetClass.methods) {
if (method.name.equals("<init>")) {
for (AbstractInsnNode instruction : method.instructions) {
if (instruction instanceof FieldInsnNode) {
FieldInsnNode fieldInsnNode = (FieldInsnNode) instruction;
if (fieldInsnNode.name.equals("$$world")) {
fieldInsnNode.name = "world";
}
}
}
}
}
}
}
private void modifyConstructor(String targetClassName, ClassNode classNode) {

View File

@ -41,6 +41,7 @@ public net.minecraft.tileentity.BeehiveTileEntity$Bee field_226977_a_ #entityDat
public net.minecraft.entity.passive.BeeEntity$PollinateGoal func_226504_l_()V #cancel
# Arclight 1.16
public net.minecraft.block.ComposterBlock func_235490_d_(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState; #resetFillState
public net.minecraft.util.text.Style <init>(Lnet/minecraft/util/text/Color;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Lnet/minecraft/util/text/event/ClickEvent;Lnet/minecraft/util/text/event/HoverEvent;Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;)V
# Bukkit
public net.minecraft.entity.player.PlayerEntity func_190531_bD()I
public net.minecraft.entity.item.ItemFrameEntity func_174859_a(Lnet/minecraft/util/Direction;)V

View File

@ -109,6 +109,7 @@
"command.arguments.EntitySelectorMixin",
"command.arguments.EntitySelectorParserMixin",
"command.impl.EffectCommandMixin",
"command.impl.ReloadCommandMixin",
"command.impl.SummonCommandMixin",
"command.impl.TeleportCommandMixin",
"command.impl.TimeCommandMixin",
@ -260,6 +261,7 @@
"inventory.InventoryMixin",
"inventory.MerchantInventoryMixin",
"inventory.container.AbstractFurnaceContainerMixin",
"inventory.container.AbstractRepairContainerMixin",
"inventory.container.BeaconContainerMixin",
"inventory.container.BrewingStandContainerMixin",
"inventory.container.CartographyContainer2Mixin",
@ -284,6 +286,7 @@
"inventory.container.RepairContainerMixin",
"inventory.container.ShulkerBoxContainerMixin",
"inventory.container.SlotMixin",
"inventory.container.SmithingTableContainerMixin",
"inventory.container.StonecutterContainerMixin",
"inventory.container.WorkbenchContainerMixin",
"item.ArmorStandItemMixin",
@ -386,6 +389,8 @@
"util.FoodStatsMixin",
"util.IndirectEntityDamageSourceMixin",
"util.IWorldPosCallableMixin",
"util.text.ColorMixin",
"util.text.StyleMixin",
"village.VillageSiegeMixin",
"world.ExplosionMixin",
"world.IBlockReaderMixin",
@ -422,6 +427,8 @@
"world.storage.DerivedWorldInfoMixin",
"world.storage.MapData_MapInfoMixin",
"world.storage.MapDataMixin",
"world.storage.SaveFormat_LevelSaveMixin",
"world.storage.SaveFormatMixin",
"world.storage.SaveHandlerMixin",
"world.storage.WorldInfoMixin",
"world.storage.loot.LootParametersMixin",

View File

@ -1,6 +1,6 @@
{
"pack": {
"description": "Arclight resources",
"pack_format": 4
"pack_format": 6
}
}