Merge branch 'master' into scoreboard-criterion-mod

This commit is contained in:
replaceitem authored and GitHub committed 2020-12-16 20:40:29 +01:00
commit 6bb7eb2ae2
63 files changed
+2386 -797

No files matched your search

@@ -8,13 +8,11 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(HungerManager.class)
public class HungerManagerMixin_scarpetEventsMixin implements HungerManagerInterface {
@Shadow private float exhaustion;
public float getExhaustionCM(){
return exhaustion;
}
@Shadow private float foodSaturationLevel;
@Override
public void setExhaustionCM(float exhaust)
{
exhaustion = exhaust;
}
public float getExhaustionCM(){ return exhaustion; }
@Override
public void setExhaustionCM(float exhaust) { exhaustion = exhaust; }
@Override
public void setSaturationCM(float saturn) { foodSaturationLevel = saturn; }
}
@@ -69,7 +69,7 @@ public abstract class PlayerManager_fakePlayersMixin
ServerPlayerEntity serverPlayerEntity_3 = (ServerPlayerEntity) var5.next();
if(serverPlayerEntity_3 instanceof EntityPlayerMPFake)
{
serverPlayerEntity_3.kill();
((EntityPlayerMPFake)serverPlayerEntity_3).kill(new TranslatableText("multiplayer.disconnect.duplicate_login"));
continue;
}
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
@@ -1,6 +1,7 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.ServerWorldInterface;
import carpet.script.CarpetEventServer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LightningEntity;
@@ -9,7 +10,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.level.ServerWorldProperties;
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;
@@ -19,7 +22,7 @@ import static carpet.script.CarpetEventServer.Event.ENTITY_LOAD;
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
@Mixin(ServerWorld.class)
public class ServerWorld_scarpetEventMixin
public class ServerWorld_scarpetMixin implements ServerWorldInterface
{
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
value = "INVOKE",
@@ -54,4 +57,9 @@ public class ServerWorld_scarpetEventMixin
}
}
@Shadow
private ServerWorldProperties worldProperties;
public ServerWorldProperties getWorldPropertiesCM(){
return worldProperties;
}
}
@@ -0,0 +1,34 @@
package carpet.mixins;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.TradeOutputSlot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.village.Merchant;
import net.minecraft.village.MerchantInventory;
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;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import static carpet.script.CarpetEventServer.Event.PLAYER_TRADES;
@Mixin(value = TradeOutputSlot.class)
public abstract class TradeOutputSlot_scarpetEventMixin {
@Shadow @Final private Merchant merchant;
@Shadow @Final private MerchantInventory merchantInventory;
@Inject(method = "onTakeItem", at = @At(value = "INVOKE",
target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V")
)
private void onTrade(PlayerEntity player, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) {
if(PLAYER_TRADES.isNeeded() && !this.merchant.getMerchantWorld().isClient())
{
PLAYER_TRADES.onTrade((ServerPlayerEntity) player, merchant, merchantInventory.getTradeOffer());
}
}
}