Skip to content

Commit

Permalink
22w43a
Browse files Browse the repository at this point in the history
  • Loading branch information
gnembon committed Oct 26, 2022
1 parent 1c2b1df commit e0b6aae
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html
minecraft_version=22w42a
minecraft_version=22w43a
loader_version=0.14.10
fabric_version=0.58.0+1.19
fabric_version=0.65.1+1.19.3

# Mod Properties
mod_version = 1.4.85
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/carpet/helpers/OptimizedExplosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static void doExplosionB(Explosion e, boolean spawnParticles)

// If it is needed, calls scarpet event
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClientSide()) {
EXPLOSION_OUTCOME.onExplosion((ServerLevel) world, eAccess.getSource(), e::getSourceMob, eAccess.getX(), eAccess.getY(), eAccess.getZ(), eAccess.getRadius(), eAccess.isFire(), e.getToBlow(), entityList, eAccess.getBlockInteraction());
EXPLOSION_OUTCOME.onExplosion((ServerLevel) world, eAccess.getSource(), e::getIndirectSourceEntity, eAccess.getX(), eAccess.getY(), eAccess.getZ(), eAccess.getRadius(), eAccess.isFire(), e.getToBlow(), entityList, eAccess.getBlockInteraction());
}

boolean damagesTerrain = eAccess.getBlockInteraction() != Explosion.BlockInteraction.NONE;
Expand Down Expand Up @@ -234,7 +234,7 @@ public static void doExplosionB(Explosion e, boolean spawnParticles)
ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList = new ObjectArrayList<>();
Util.shuffle((ObjectArrayList<BlockPos>) e.getToBlow(), world.random);

boolean dropFromExplosions = CarpetSettings.xpFromExplosions || e.getSourceMob() instanceof Player;
boolean dropFromExplosions = CarpetSettings.xpFromExplosions || e.getIndirectSourceEntity() instanceof Player;

for (BlockPos blockpos : e.getToBlow())
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class Explosion_scarpetEventMixin
@Shadow @Final private Explosion.BlockInteraction blockInteraction;
@Shadow @Final private @Nullable Entity source;

@Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getSourceMob();
@Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getIndirectSourceEntity();

@Shadow public static float getSeenPercent(Vec3 source, Entity entity) {return 0.0f;}

Expand Down Expand Up @@ -71,7 +71,7 @@ private void onExplosion(boolean spawnParticles, CallbackInfo ci)
{
if (EXPLOSION_OUTCOME.isNeeded() && !level.isClientSide())
{
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getSourceMob, x, y, z, radius, fire, toBlow, affectedEntities, blockInteraction);
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, x, y, z, radius, fire, toBlow, affectedEntities, blockInteraction);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import carpet.network.CarpetClient;
import carpet.script.utils.ShapesRenderer;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
Expand All @@ -12,6 +11,7 @@
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public EntityPlayerActionPack getActionPack()
}

@Inject(method = "<init>", at = @At(value = "RETURN"))
private void onServerPlayerEntityContructor(MinecraftServer minecraftServer, ServerLevel serverLevel, GameProfile gameProfile, RemoteChatSession remoteChatSession, CallbackInfo ci)
private void onServerPlayerEntityContructor(MinecraftServer minecraftServer, ServerLevel serverLevel, GameProfile gameProfile, CallbackInfo ci)
{
this.actionPack = new EntityPlayerActionPack((ServerPlayer) (Object) this);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/carpet/patches/EntityPlayerMPFake.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mojang.authlib.GameProfile;
import net.minecraft.core.UUIDUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.RemoteChatSession;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
Expand Down Expand Up @@ -62,7 +61,7 @@ public static EntityPlayerMPFake createFake(String username, MinecraftServer ser
SkullBlockEntity.updateGameprofile(gameprofile, result::set);
gameprofile = result.get();
}
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false, RemoteChatSession.UNVERIFIED);
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false);
instance.fixStartingPosition = () -> instance.moveTo(d0, d1, d2, (float) yaw, (float) pitch);
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance);
instance.teleportTo(worldIn, d0, d1, d2, (float)yaw, (float)pitch);
Expand All @@ -84,7 +83,8 @@ public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlay
player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
ServerLevel worldIn = player.getLevel();//.getWorld(player.dimension);
GameProfile gameprofile = player.getGameProfile();
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true, player.getChatSession());
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true);
playerShadow.setChatSession(player.getChatSession());
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), playerShadow);

playerShadow.setHealth(player.getHealth());
Expand All @@ -102,9 +102,9 @@ public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlay
return playerShadow;
}

private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, boolean shadow, RemoteChatSession chatSession)
private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, boolean shadow)
{
super(server, worldIn, profile, chatSession);
super(server, worldIn, profile);
isAShadow = shadow;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carpet/script/api/WorldAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ else throw new InternalExpressionException("Attacking entity needs to be a livin
// copy of ServerWorld.createExplosion #TRACK#
Explosion explosion = new Explosion(cc.s.getLevel(), source, null, null, pos.x, pos.y, pos.z, powah, createFire, mode){
@Override
public @Nullable LivingEntity getSourceMob() {
public @Nullable LivingEntity getIndirectSourceEntity() {
return theAttacker;
}
};
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/carpet/script/utils/ShapesRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -283,9 +283,9 @@ public void renderLines(PoseStack matrices, Tesselator tessellator, BufferBuilde

matrices.translate(v1.x - cx, v1.y - cy, v1.z - cz);
ShapeDirection.rotatePoseStackByShapeDirection(matrices, shape.facing, camera1, isitem ? v1 : v1.add(0.5, 0.5, 0.5));
if (shape.tilt != 0.0f) matrices.mulPose(Vector3f.ZP.rotationDegrees(-shape.tilt));
if (shape.lean != 0.0f) matrices.mulPose(Vector3f.XP.rotationDegrees(-shape.lean));
if (shape.turn != 0.0f) matrices.mulPose(Vector3f.YP.rotationDegrees( shape.turn));
if (shape.tilt != 0.0f) matrices.mulPose(Axis.ZP.rotationDegrees(-shape.tilt));
if (shape.lean != 0.0f) matrices.mulPose(Axis.XP.rotationDegrees(-shape.lean));
if (shape.turn != 0.0f) matrices.mulPose(Axis.YP.rotationDegrees( shape.turn));
matrices.scale(shape.scaleX, shape.scaleY, shape.scaleZ);

if (!isitem)
Expand All @@ -295,7 +295,7 @@ public void renderLines(PoseStack matrices, Tesselator tessellator, BufferBuilde
}
else {
// items seems to be flipped by default
matrices.mulPose(Vector3f.YP.rotationDegrees(180));
matrices.mulPose(Axis.YP.rotationDegrees(180));
}

RenderSystem.depthMask(true);
Expand Down Expand Up @@ -447,9 +447,9 @@ public void renderLines(PoseStack matrices, Tesselator tessellator, BufferBuilde

matrices.scale(shape.size* 0.0025f, -shape.size*0.0025f, shape.size*0.0025f);
//RenderSystem.scalef(shape.size* 0.0025f, -shape.size*0.0025f, shape.size*0.0025f);
if (shape.tilt!=0.0f) matrices.mulPose(Vector3f.ZP.rotationDegrees(shape.tilt));
if (shape.lean!=0.0f) matrices.mulPose(Vector3f.XP.rotationDegrees(shape.lean));
if (shape.turn!=0.0f) matrices.mulPose(Vector3f.YP.rotationDegrees(shape.turn));
if (shape.tilt!=0.0f) matrices.mulPose(Axis.ZP.rotationDegrees(shape.tilt));
if (shape.lean!=0.0f) matrices.mulPose(Axis.XP.rotationDegrees(shape.lean));
if (shape.turn!=0.0f) matrices.mulPose(Axis.YP.rotationDegrees(shape.turn));
matrices.translate(-10*shape.indent, -10*shape.height-9, (-10*renderEpsilon)-10*shape.raise);
//if (visibleThroughWalls) RenderSystem.disableDepthTest();
matrices.scale(-1, 1, 1);
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/carpet/script/utils/shapes/ShapeDirection.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package carpet.script.utils.shapes;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import net.minecraft.client.Camera;
import net.minecraft.world.phys.Vec3;

Expand Down Expand Up @@ -34,11 +34,11 @@ public static ShapeDirection fromString(String direction) {
public static void rotatePoseStackByShapeDirection(PoseStack poseStack, ShapeDirection shapeDirection, Camera camera, Vec3 objectPos) {
switch (shapeDirection) {
case NORTH -> {}
case SOUTH -> poseStack.mulPose(Vector3f.YP.rotationDegrees(180));
case EAST -> poseStack.mulPose(Vector3f.YP.rotationDegrees(270));
case WEST -> poseStack.mulPose(Vector3f.YP.rotationDegrees(90));
case UP -> poseStack.mulPose(Vector3f.XP.rotationDegrees(90));
case DOWN -> poseStack.mulPose(Vector3f.XP.rotationDegrees(-90));
case SOUTH -> poseStack.mulPose(Axis.YP.rotationDegrees(180));
case EAST -> poseStack.mulPose(Axis.YP.rotationDegrees(270));
case WEST -> poseStack.mulPose(Axis.YP.rotationDegrees(90));
case UP -> poseStack.mulPose(Axis.XP.rotationDegrees(90));
case DOWN -> poseStack.mulPose(Axis.XP.rotationDegrees(-90));
case CAMERA -> poseStack.mulPose(camera.rotation());
case PLAYER -> {
final Vec3 vector = objectPos.subtract(camera.getPosition());
Expand All @@ -52,8 +52,8 @@ public static void rotatePoseStackByShapeDirection(PoseStack poseStack, ShapeDir
// that should work somehow but it doesn't for some reason
//matrices.mulPose(new Quaternion( -rotY, rotX, 0, false));

poseStack.mulPose(Vector3f.YP.rotation(rotX));
poseStack.mulPose(Vector3f.XP.rotation(-rotY));
poseStack.mulPose(Axis.YP.rotation(rotX));
poseStack.mulPose(Axis.XP.rotation(-rotY));
}
}
}
Expand Down

0 comments on commit e0b6aae

Please sign in to comment.