21w08a
- rework on handling /log packets - rework on player attack and interaction with entities - rework display_title (need recheck) - rework packets for structure blocks
This commit is contained in:
1 parent
3505138351
commit
2cf403057c
12 files changed
+95
-41
No files matched your search
@@ -8,14 +8,19 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.world.World;
|
||||
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.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_ATTACKS_ENTITY;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_DEALS_DAMAGE;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_ENTITY;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_TAKES_DAMAGE;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_COLLIDES_WITH_ENTITY;
|
||||
|
||||
@@ -53,4 +58,22 @@ public abstract class PlayerEntity_scarpetEventsMixin extends LivingEntity
|
||||
PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayerEntity)(Object)this, entity, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "interact", at = @At("HEAD"))
|
||||
private void doInteract(Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir)
|
||||
{
|
||||
if (!world.isClient && PLAYER_INTERACTS_WITH_ENTITY.isNeeded())
|
||||
{
|
||||
PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayerEntity) (Object)this, entity, hand);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "attack", at = @At("HEAD"))
|
||||
private void onAttack(Entity target, CallbackInfo ci)
|
||||
{
|
||||
if (!world.isClient && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable())
|
||||
{
|
||||
PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayerEntity) (Object)this, target, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,16 +225,16 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
PLAYER_DEPLOYS_ELYTRA.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
/*@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;interact(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"
|
||||
))
|
||||
private void onEntityInteract(PlayerInteractEntityC2SPacket playerInteractEntityC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), playerInteractEntityC2SPacket_1.getHand());
|
||||
}
|
||||
}*/
|
||||
|
||||
@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
/*@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;attack(Lnet/minecraft/entity/Entity;)V"
|
||||
))
|
||||
@@ -242,7 +242,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
{
|
||||
//todo add hit and hand in the future
|
||||
PLAYER_ATTACKS_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), null);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Inject(method = "onButtonClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V"))
|
||||
private void onItemBeingPickedFromInventory(ButtonClickC2SPacket packet, CallbackInfo ci)
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
|
||||
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();
|
||||
|
||||
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, C config, HeightLimitView heightLimitView);
|
||||
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView);
|
||||
|
||||
@Override
|
||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config)
|
||||
@@ -105,10 +105,10 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
if (biome == null)
|
||||
biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
|
||||
|
||||
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed());
|
||||
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos, BlockBox.empty(),0,worldIn.getSeed());
|
||||
if (config == null)
|
||||
config = new DefaultFeatureConfig();
|
||||
structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config, ichunk);
|
||||
structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, biome_1, config, ichunk);
|
||||
structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;
|
||||
|
||||
if (structurestart.hasChildren())
|
||||
@@ -121,8 +121,8 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
|
||||
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
|
||||
{
|
||||
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, i, j, biome, chunkPos, featureConfig, heightLimitView);
|
||||
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, chpos, biome, chunkPos, featureConfig, heightLimitView);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class UpdateStructureBlockC2SPacketMixin {
|
||||
private BlockPos size;
|
||||
|
||||
@Inject(
|
||||
method = "read",
|
||||
method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V",
|
||||
at = @At("TAIL")
|
||||
)
|
||||
private void structureBlockLimitsRead(PacketByteBuf buf, CallbackInfo ci) {
|
||||
|
||||
Reference in new issue
Block a user