update to 24w33a
This commit is contained in:
1 parent
9940feb7d3
commit
d11586fdaf
58 files changed
+379
-875
No files matched your search
+3
-3
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=1.21.1
|
||||
minecraft_version=24w33a
|
||||
loader_version=0.15.11
|
||||
jsr305_version=3.0.2
|
||||
fabric_version=0.99.2+1.21
|
||||
fabric_version=0.102.0+1.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.4.147
|
||||
@@ -17,7 +17,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5)
|
||||
# This is needed because CF uses too vague names for prereleases and release candidates
|
||||
# Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN]
|
||||
release-curse-versions = Minecraft 1.21.1:1.21.1
|
||||
release-curse-versions = Minecraft 1.21.2:1.21.2-Snapshot
|
||||
# Whether or not to build another branch on release
|
||||
release-extra-branch = false
|
||||
# The name of the second branch to release
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
||||
@@ -54,7 +55,7 @@ public class PerimeterInfoCommand
|
||||
if (mobId != null)
|
||||
{
|
||||
nbttagcompound.putString("id", mobId);
|
||||
Entity baseEntity = EntityType.loadEntityRecursive(nbttagcompound, source.getLevel(), (entity_1x) -> {
|
||||
Entity baseEntity = EntityType.loadEntityRecursive(nbttagcompound, source.getLevel(), EntitySpawnReason.COMMAND, (entity_1x) -> {
|
||||
entity_1x.moveTo(new BlockPos(pos.getX(), source.getLevel().getMinBuildHeight()-10, pos.getZ()), entity_1x.getYRot(), entity_1x. getXRot());
|
||||
return !source.getLevel().addWithUUID(entity_1x) ? null : entity_1x;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
|
||||
public interface DefaultRedstoneWireEvaluatorInferface
|
||||
{
|
||||
int calculateTargetStrengthCM(final Level level, final BlockPos pos);
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public interface IngredientInterface
|
||||
* Gets all the stacks of the ingredients for a given item recipe. Also used for {@link carpet.helpers.HopperCounter#guessColor}
|
||||
* to guess the colour of an item to display it prettily
|
||||
*/
|
||||
List<Collection<ItemStack>> getRecipeStacks();
|
||||
//List<Collection<ItemStack>> getRecipeStacks();
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class BlockRotator
|
||||
}
|
||||
}
|
||||
// Send block update to the block that just have been rotated.
|
||||
world.neighborChanged(blockpos, block, source.pos());
|
||||
world.neighborChanged(blockpos, block, null);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import carpet.script.utils.Tracer;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetHeldSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -282,7 +282,7 @@ public class EntityPlayerActionPack
|
||||
public void setSlot(int slot)
|
||||
{
|
||||
player.getInventory().selected = slot-1;
|
||||
player.connection.send(new ClientboundSetCarriedItemPacket(slot-1));
|
||||
player.connection.send(new ClientboundSetHeldSlotPacket(slot-1));
|
||||
}
|
||||
|
||||
public enum ActionType
|
||||
@@ -317,9 +317,9 @@ public class EntityPlayerActionPack
|
||||
if (pos.getY() < player.level().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
|
||||
{
|
||||
InteractionResult result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit);
|
||||
if (result.consumesAction())
|
||||
if (result instanceof InteractionResult.Success success)
|
||||
{
|
||||
if (result.shouldSwing()) player.swing(hand);
|
||||
if (success.swingSource() == InteractionResult.SwingSource.SERVER) player.swing(hand);
|
||||
ap.itemUseCooldown = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.fakes.IngredientInterface;
|
||||
import carpet.fakes.RecipeManagerInterface;
|
||||
import carpet.utils.Messenger;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap;
|
||||
@@ -22,7 +21,7 @@ import net.minecraft.world.item.DyeItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.PlacementInfo;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.block.AbstractBannerBlock;
|
||||
@@ -32,12 +31,12 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
@@ -376,16 +375,13 @@ public class HopperCounter
|
||||
{
|
||||
for (Recipe<?> r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id, registryAccess))
|
||||
{
|
||||
for (Ingredient ingredient: r.getIngredients())
|
||||
for (Optional<PlacementInfo.SlotInfo> ingredient: r.placementInfo().slotInfo())
|
||||
{
|
||||
for (Collection<ItemStack> stacks : ((IngredientInterface) (Object) ingredient).getRecipeStacks())
|
||||
for(ItemStack stack : ingredient.get().possibleItems())
|
||||
{
|
||||
for (ItemStack iStak : stacks)
|
||||
{
|
||||
TextColor cand = fromItem(iStak.getItem(), registryAccess);
|
||||
if (cand != null)
|
||||
return cand;
|
||||
}
|
||||
TextColor cand = fromItem(stack.getItem(), registryAccess);
|
||||
if (cand != null)
|
||||
return cand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,39 @@
|
||||
package carpet.helpers;
|
||||
//Author: masa
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.item.PrimedTnt;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import carpet.logging.logHelpers.ExplosionLogHelper;
|
||||
import carpet.mixins.ExplosionAccessor;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.utils.Messenger;
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION_OUTCOME;
|
||||
|
||||
public class OptimizedExplosion
|
||||
{
|
||||
private static List<Entity> entitylist;
|
||||
private static Vec3 vec3dmem;
|
||||
private static long tickmem;
|
||||
// For disabling the explosion particles and sound
|
||||
public static int explosionSound = 0;
|
||||
|
||||
// masa's optimizations
|
||||
private static Object2DoubleOpenHashMap<Pair<Vec3, AABB>> densityCache = new Object2DoubleOpenHashMap<>();
|
||||
private static MutablePair<Vec3, AABB> pairMutable = new MutablePair<>();
|
||||
private static Object2ObjectOpenHashMap<BlockPos, BlockState> stateCache = new Object2ObjectOpenHashMap<>();
|
||||
private static Object2ObjectOpenHashMap<BlockPos, FluidState> fluidCache = new Object2ObjectOpenHashMap<>();
|
||||
private static BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||
private static ObjectOpenHashSet<BlockPos> affectedBlockPositionsSet = new ObjectOpenHashSet<>();
|
||||
private static boolean firstRay;
|
||||
private static boolean rayCalcDone;
|
||||
private static ArrayList<Float> chances = new ArrayList<>();
|
||||
private static BlockPos blastChanceLocation;
|
||||
|
||||
// Creating entity list for scarpet event
|
||||
private static List<Entity> entityList = new ArrayList<>();
|
||||
|
||||
public static void doExplosionA(Explosion e, ExplosionLogHelper eLogger) {
|
||||
public static List<BlockPos> doExplosionA(Explosion e, ExplosionLogHelper eLogger) {
|
||||
ExplosionAccessor eAccess = (ExplosionAccessor) e;
|
||||
|
||||
entityList.clear();
|
||||
boolean eventNeeded = EXPLOSION_OUTCOME.isNeeded() && !eAccess.getLevel().isClientSide();
|
||||
blastCalc(e);
|
||||
|
||||
List<BlockPos> toBlow;
|
||||
|
||||
if (!CarpetSettings.explosionNoBlockDamage && eAccess.getDamageSource() != null) {
|
||||
rayCalcDone = false;
|
||||
@@ -88,291 +47,14 @@ public class OptimizedExplosion
|
||||
stateCache.clear();
|
||||
fluidCache.clear();
|
||||
|
||||
e.getToBlow().addAll(affectedBlockPositionsSet);
|
||||
toBlow = new ArrayList<>(affectedBlockPositionsSet);
|
||||
affectedBlockPositionsSet.clear();
|
||||
} else {
|
||||
toBlow = Collections.emptyList();
|
||||
}
|
||||
|
||||
float f3 = eAccess.getRadius() * 2.0F;
|
||||
int k1 = Mth.floor(eAccess.getX() - (double) f3 - 1.0D);
|
||||
int l1 = Mth.floor(eAccess.getX() + (double) f3 + 1.0D);
|
||||
int i2 = Mth.floor(eAccess.getY() - (double) f3 - 1.0D);
|
||||
int i1 = Mth.floor(eAccess.getY() + (double) f3 + 1.0D);
|
||||
int j2 = Mth.floor(eAccess.getZ() - (double) f3 - 1.0D);
|
||||
int j1 = Mth.floor(eAccess.getZ() + (double) f3 + 1.0D);
|
||||
Vec3 vec3d = new Vec3(eAccess.getX(), eAccess.getY(), eAccess.getZ());
|
||||
|
||||
if (vec3dmem == null || !vec3dmem.equals(vec3d) || tickmem != eAccess.getLevel().getGameTime()) {
|
||||
vec3dmem = vec3d;
|
||||
tickmem = eAccess.getLevel().getGameTime();
|
||||
entitylist = eAccess.getLevel().getEntities(null, new AABB(k1, i2, j2, l1, i1, j1));
|
||||
explosionSound = 0;
|
||||
}
|
||||
|
||||
explosionSound++;
|
||||
|
||||
Entity explodingEntity = eAccess.getSource();
|
||||
for (int k2 = 0; k2 < entitylist.size(); ++k2) {
|
||||
Entity entity = entitylist.get(k2);
|
||||
|
||||
|
||||
if (entity == explodingEntity) {
|
||||
// entitylist.remove(k2);
|
||||
removeFast(entitylist, k2);
|
||||
k2--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entity instanceof PrimedTnt && explodingEntity != null &&
|
||||
entity.getX() == explodingEntity.getX() &&
|
||||
entity.getY() == explodingEntity.getY() &&
|
||||
entity.getZ() == explodingEntity.getZ()) {
|
||||
if (eLogger != null) {
|
||||
eLogger.onEntityImpacted(entity, new Vec3(0,-0.9923437498509884d, 0));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entity.ignoreExplosion(e)) {
|
||||
double d12 = Math.sqrt(entity.distanceToSqr(eAccess.getX(), eAccess.getY(), eAccess.getZ())) / (double) f3;
|
||||
|
||||
if (d12 <= 1.0D) {
|
||||
double d5 = entity.getX() - eAccess.getX();
|
||||
// Change in 1.16 snapshots to fix a bug with TNT jumping
|
||||
double d7 = (entity instanceof PrimedTnt ? entity.getY() : entity.getEyeY()) - eAccess.getY();
|
||||
double d9 = entity.getZ() - eAccess.getZ();
|
||||
double d13 = (double) Math.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
|
||||
|
||||
if (d13 != 0.0D) {
|
||||
d5 = d5 / d13;
|
||||
d7 = d7 / d13;
|
||||
d9 = d9 / d13;
|
||||
double density;
|
||||
|
||||
pairMutable.setLeft(vec3d);
|
||||
pairMutable.setRight(entity.getBoundingBox());
|
||||
density = densityCache.getOrDefault(pairMutable, Double.MAX_VALUE);
|
||||
|
||||
if (density == Double.MAX_VALUE)
|
||||
{
|
||||
Pair<Vec3, AABB> pair = Pair.of(vec3d, entity.getBoundingBox());
|
||||
density = Explosion.getSeenPercent(vec3d, entity);
|
||||
densityCache.put(pair, density);
|
||||
}
|
||||
|
||||
// If it is needed, it saves the entity
|
||||
if (eventNeeded) {
|
||||
entityList.add(entity);
|
||||
}
|
||||
|
||||
double d10 = (1.0D - d12) * density;
|
||||
if (eAccess.getDamageSource() != null)
|
||||
{
|
||||
entity.hurt(eAccess.getDamageSource(),
|
||||
(float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
}
|
||||
double d11 = d10;
|
||||
|
||||
if (entity instanceof LivingEntity lev) {
|
||||
d11 = d10 * Mth.clamp(1.0 - lev.getAttributeValue(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE), 0.0, 1.0);
|
||||
}
|
||||
|
||||
if (eLogger != null) {
|
||||
eLogger.onEntityImpacted(entity, new Vec3(d5 * d11, d7 * d11, d9 * d11));
|
||||
}
|
||||
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(d5 * d11, d7 * d11, d9 * d11));
|
||||
|
||||
if (entity instanceof Player player) {
|
||||
|
||||
if (!player.isSpectator()
|
||||
&& (!player.isCreative() || !player.getAbilities().flying)) { //getAbilities
|
||||
e.getHitPlayers().put(player, new Vec3(d5 * d10, d7 * d10, d9 * d10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
densityCache.clear();
|
||||
}
|
||||
|
||||
public static void doExplosionB(Explosion e, boolean spawnParticles)
|
||||
{
|
||||
ExplosionAccessor eAccess = (ExplosionAccessor) e;
|
||||
Level world = eAccess.getLevel();
|
||||
double posX = eAccess.getX();
|
||||
double posY = eAccess.getY();
|
||||
double posZ = eAccess.getZ();
|
||||
|
||||
// If it is needed, calls scarpet event
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClientSide()) {
|
||||
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.KEEP;
|
||||
|
||||
// explosionSound incremented till disabling the explosion particles and sound
|
||||
if (explosionSound < 100 || explosionSound % 100 == 0)
|
||||
{
|
||||
world.playSound(null, posX, posY, posZ, SoundEvents.GENERIC_EXPLODE.value(), SoundSource.BLOCKS, 4.0F,
|
||||
(1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F);
|
||||
|
||||
if (spawnParticles)
|
||||
{
|
||||
if (eAccess.getRadius() >= 2.0F && damagesTerrain)
|
||||
{
|
||||
world.addParticle(ParticleTypes.EXPLOSION_EMITTER, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.addParticle(ParticleTypes.EXPLOSION, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (damagesTerrain)
|
||||
{
|
||||
ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList = new ObjectArrayList<>();
|
||||
Util.shuffle((ObjectArrayList<BlockPos>) e.getToBlow(), world.random);
|
||||
|
||||
boolean dropFromExplosions = CarpetSettings.xpFromExplosions || e.getIndirectSourceEntity() instanceof Player;
|
||||
|
||||
for (BlockPos blockpos : e.getToBlow())
|
||||
{
|
||||
BlockState state = world.getBlockState(blockpos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (!state.isAir())
|
||||
{
|
||||
if (block.dropFromExplosion(e) && world instanceof ServerLevel serverLevel)
|
||||
{
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(blockpos) : null; //hasBlockEntity()
|
||||
|
||||
LootParams.Builder lootBuilder = (new LootParams.Builder((ServerLevel)eAccess.getLevel()))
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockpos))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, blockEntity)
|
||||
.withOptionalParameter(LootContextParams.THIS_ENTITY, eAccess.getSource());
|
||||
|
||||
if (eAccess.getBlockInteraction() == Explosion.BlockInteraction.DESTROY_WITH_DECAY)
|
||||
lootBuilder.withParameter(LootContextParams.EXPLOSION_RADIUS, eAccess.getRadius());
|
||||
|
||||
state.spawnAfterBreak(serverLevel, blockpos, ItemStack.EMPTY, dropFromExplosions);
|
||||
|
||||
state.getDrops(lootBuilder).forEach((itemStackx) -> {
|
||||
method_24023(objectArrayList, itemStackx, blockpos.immutable());
|
||||
});
|
||||
}
|
||||
|
||||
world.setBlock(blockpos, Blocks.AIR.defaultBlockState(), 3);
|
||||
block.wasExploded(world, blockpos, e);
|
||||
}
|
||||
}
|
||||
objectArrayList.forEach(p -> Block.popResource(world, p.getRight(), p.getLeft()));
|
||||
|
||||
}
|
||||
|
||||
if (eAccess.isFire())
|
||||
{
|
||||
for (BlockPos blockpos1 : e.getToBlow())
|
||||
{
|
||||
// Use the same Chunk reference because the positions are in the same xz-column
|
||||
ChunkAccess chunk = world.getChunk(blockpos1.getX() >> 4, blockpos1.getZ() >> 4);
|
||||
|
||||
BlockPos down = blockpos1.below(1);
|
||||
if (eAccess.getRandom().nextInt(3) == 0 &&
|
||||
chunk.getBlockState(blockpos1).isAir() &&
|
||||
chunk.getBlockState(down).isSolidRender(world, down)
|
||||
)
|
||||
{
|
||||
world.setBlockAndUpdate(blockpos1, Blocks.FIRE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copied from Explosion, need to move the code to the explosion code anyways and use shadows for
|
||||
// simplicity, its not jarmodding anyways
|
||||
private static void method_24023(ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList, ItemStack itemStack, BlockPos blockPos) {
|
||||
int i = objectArrayList.size();
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
Pair<ItemStack, BlockPos> pair = objectArrayList.get(j);
|
||||
ItemStack itemStack2 = pair.getLeft();
|
||||
if (ItemEntity.areMergable(itemStack2, itemStack)) {
|
||||
ItemStack itemStack3 = ItemEntity.merge(itemStack2, itemStack, 16);
|
||||
objectArrayList.set(j, Pair.of(itemStack3, pair.getRight()));
|
||||
if (itemStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
objectArrayList.add(Pair.of(itemStack, blockPos));
|
||||
}
|
||||
|
||||
private static void removeFast(List<Entity> lst, int index) {
|
||||
if (index < lst.size() - 1)
|
||||
lst.set(index, lst.get(lst.size() - 1));
|
||||
lst.remove(lst.size() - 1);
|
||||
}
|
||||
|
||||
private static void rayCalcs(Explosion e) {
|
||||
ExplosionAccessor eAccess = (ExplosionAccessor) e;
|
||||
boolean first = true;
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
for (int k = 0; k < 16; ++k) {
|
||||
for (int l = 0; l < 16; ++l) {
|
||||
if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
|
||||
double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
|
||||
double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
|
||||
double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F);
|
||||
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
||||
d0 = d0 / d3;
|
||||
d1 = d1 / d3;
|
||||
d2 = d2 / d3;
|
||||
float rand = eAccess.getLevel().random.nextFloat();
|
||||
if (CarpetSettings.tntRandomRange >= 0) {
|
||||
rand = (float) CarpetSettings.tntRandomRange;
|
||||
}
|
||||
float f = eAccess.getRadius() * (0.7F + rand * 0.6F);
|
||||
double d4 = eAccess.getX();
|
||||
double d6 = eAccess.getY();
|
||||
double d8 = eAccess.getZ();
|
||||
|
||||
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
||||
BlockPos blockpos = BlockPos.containing(d4, d6, d8);
|
||||
BlockState state = eAccess.getLevel().getBlockState(blockpos);
|
||||
FluidState fluidState = eAccess.getLevel().getFluidState(blockpos);
|
||||
|
||||
if (!state.isAir()) {
|
||||
float f2 = Math.max(state.getBlock().getExplosionResistance(), fluidState.getExplosionResistance());
|
||||
if (eAccess.getSource() != null)
|
||||
f2 = eAccess.getSource().getBlockExplosionResistance(e, eAccess.getLevel(), blockpos, state, fluidState, f2);
|
||||
f -= (f2 + 0.3F) * 0.3F;
|
||||
}
|
||||
|
||||
if (f > 0.0F && (eAccess.getSource() == null ||
|
||||
eAccess.getSource().shouldBlockExplode(e, eAccess.getLevel(), blockpos, state, f)))
|
||||
{
|
||||
affectedBlockPositionsSet.add(blockpos);
|
||||
}
|
||||
else if (first) {
|
||||
return;
|
||||
}
|
||||
|
||||
first = false;
|
||||
|
||||
d4 += d0 * 0.30000001192092896D;
|
||||
d6 += d1 * 0.30000001192092896D;
|
||||
d8 += d2 * 0.30000001192092896D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return toBlow;
|
||||
}
|
||||
|
||||
private static void getAffectedPositionsOnPlaneX(Explosion e, int x, int yStart, int yEnd, int zStart, int zEnd)
|
||||
@@ -454,9 +136,10 @@ public class OptimizedExplosion
|
||||
float rand = eAccess.getLevel().random.nextFloat();
|
||||
float sizeRand = (CarpetSettings.tntRandomRange >= 0 ? (float) CarpetSettings.tntRandomRange : rand);
|
||||
float size = eAccess.getRadius() * (0.7F + sizeRand * 0.6F);
|
||||
double posX = eAccess.getX();
|
||||
double posY = eAccess.getY();
|
||||
double posZ = eAccess.getZ();
|
||||
Vec3 vec3 = eAccess.getCenter();
|
||||
double posX = vec3.x;
|
||||
double posY = vec3.y;
|
||||
double posZ = vec3.z;
|
||||
|
||||
for (float f1 = 0.3F; size > 0.0F; size -= 0.22500001F)
|
||||
{
|
||||
@@ -508,112 +191,4 @@ public class OptimizedExplosion
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setBlastChanceLocation(BlockPos p){
|
||||
blastChanceLocation = p;
|
||||
}
|
||||
|
||||
private static void blastCalc(Explosion e){
|
||||
ExplosionAccessor eAccess = (ExplosionAccessor) e;
|
||||
if(blastChanceLocation == null || blastChanceLocation.distToLowCornerSqr(eAccess.getX(), eAccess.getY(), eAccess.getZ()) > 200) return;
|
||||
chances.clear();
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
for (int k = 0; k < 16; ++k) {
|
||||
for (int l = 0; l < 16; ++l) {
|
||||
if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
|
||||
double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
|
||||
double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
|
||||
double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F);
|
||||
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
||||
d0 = d0 / d3;
|
||||
d1 = d1 / d3;
|
||||
d2 = d2 / d3;
|
||||
float f = eAccess.getRadius() * (0.7F + 0.6F);
|
||||
double d4 = eAccess.getX();
|
||||
double d6 = eAccess.getY();
|
||||
double d8 = eAccess.getZ();
|
||||
boolean found = false;
|
||||
|
||||
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
||||
BlockPos blockpos = BlockPos.containing(d4, d6, d8);
|
||||
BlockState state = eAccess.getLevel().getBlockState(blockpos);
|
||||
FluidState fluidState = eAccess.getLevel().getFluidState(blockpos);
|
||||
|
||||
if (!state.isAir()) {
|
||||
float f2 = Math.max(state.getBlock().getExplosionResistance(), fluidState.getExplosionResistance());
|
||||
if (eAccess.getSource() != null)
|
||||
f2 = eAccess.getSource().getBlockExplosionResistance(e, eAccess.getLevel(), blockpos, state, fluidState, f2);
|
||||
f -= (f2 + 0.3F) * 0.3F;
|
||||
}
|
||||
|
||||
if (f > 0.0F && (eAccess.getSource() == null ||
|
||||
eAccess.getSource().shouldBlockExplode(e, eAccess.getLevel(), blockpos, state, f))) {
|
||||
if(!found && blockpos.equals(blastChanceLocation)){
|
||||
chances.add(f);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
d4 += d0 * 0.30000001192092896D;
|
||||
d6 += d1 * 0.30000001192092896D;
|
||||
d8 += d2 * 0.30000001192092896D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//showTNTblastChance(e);
|
||||
}
|
||||
|
||||
private static void showTNTblastChance(Explosion e){
|
||||
ExplosionAccessor eAccess = (ExplosionAccessor) e;
|
||||
double randMax = 0.6F * eAccess.getRadius();
|
||||
double total = 0;
|
||||
boolean fullyBlownUp = false;
|
||||
boolean first = true;
|
||||
int rays = 0;
|
||||
for(float f3 : chances){
|
||||
rays++;
|
||||
double calc = f3 - randMax;
|
||||
if(calc > 0) fullyBlownUp = true;
|
||||
double chancePerRay = (Math.abs(calc) / randMax);
|
||||
if(!fullyBlownUp){
|
||||
if(first){
|
||||
first = false;
|
||||
total = chancePerRay;
|
||||
}else {
|
||||
total = total * chancePerRay;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(fullyBlownUp) total = 0;
|
||||
double chance = 1 - total;
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
nf.setRoundingMode (RoundingMode.DOWN);
|
||||
nf.setMaximumFractionDigits(2);
|
||||
for(Player player : eAccess.getLevel().players()){
|
||||
Messenger.m(player,"w Pop: ",
|
||||
"c " + nf.format(chance) + " ",
|
||||
"^w Chance for the block to be destroyed by the blast: " + chance,
|
||||
"?" + chance,
|
||||
"w Remain: ",
|
||||
String.format("c %.2f ", total),
|
||||
"^w Chance the block survives the blast: " + total,
|
||||
"?" + total,
|
||||
"w Rays: ",
|
||||
String.format("c %d ", rays),
|
||||
"^w TNT blast rays going through the block",
|
||||
"?" + rays,
|
||||
"w Size: ",
|
||||
String.format("c %.1f ", eAccess.getRadius()),
|
||||
"^w TNT blast size",
|
||||
"?" + eAccess.getRadius(),
|
||||
"w @: ",
|
||||
String.format("c [%.1f %.1f %.1f] ", eAccess.getX(), eAccess.getY(), eAccess.getZ()),
|
||||
"^w TNT blast location X:" + eAccess.getX() + " Y:" + eAccess.getY() + " Z:" + eAccess.getZ(),
|
||||
"?" + eAccess.getX() + " " + eAccess.getY() + " " + eAccess.getZ()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -676,7 +676,7 @@ public class RedstoneWireTurbo
|
||||
// call BlockStateBase#neighborChanged directly. This change mostly
|
||||
// restores old behavior, at the cost of bypassing the
|
||||
// max-chained-neighbor-updates server property.
|
||||
worldIn.getBlockState(upd.self).handleNeighborChanged(worldIn, upd.self, wire, upd.parent, false);
|
||||
worldIn.getBlockState(upd.self).handleNeighborChanged(worldIn, upd.self, wire, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import carpet.CarpetSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.cauldron.CauldronInteraction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -21,14 +21,14 @@ public class AbstractCauldronBlock_stackableSBoxesMixin
|
||||
{
|
||||
@Redirect(method = "useItemOn", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/core/cauldron/CauldronInteraction;interact(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/ItemInteractionResult;"
|
||||
target = "Lnet/minecraft/core/cauldron/CauldronInteraction;interact(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/InteractionResult;"
|
||||
))
|
||||
private ItemInteractionResult wrapInteractor(final CauldronInteraction cauldronBehavior, final BlockState blockState, final Level world, final BlockPos blockPos, final Player playerEntity, final InteractionHand hand, final ItemStack itemStack)
|
||||
private InteractionResult wrapInteractor(final CauldronInteraction cauldronBehavior, final BlockState blockState, final Level world, final BlockPos blockPos, final Player playerEntity, final InteractionHand hand, final ItemStack itemStack)
|
||||
{
|
||||
int count = -1;
|
||||
if (CarpetSettings.shulkerBoxStackSize > 1 && itemStack.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
count = itemStack.getCount();
|
||||
ItemInteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
|
||||
InteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
|
||||
if (count > 0 && result.consumesAction())
|
||||
{
|
||||
ItemStack current = playerEntity.getItemInHand(hand);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.AbstractContainerMenuInterface;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractCraftingMenu;
|
||||
import net.minecraft.world.inventory.RecipeBookMenu;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
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(AbstractCraftingMenu.class)
|
||||
public class AbstractCraftingMenu_scarpetMixin
|
||||
{
|
||||
@Inject(method = "handlePlacement",at = @At("HEAD"), cancellable = true)
|
||||
private void selectRecipeCallback(boolean craftAll, boolean b, RecipeHolder<?> recipe, Inventory player, CallbackInfoReturnable<RecipeBookMenu.PostPlaceAction> cir) {
|
||||
if(((AbstractContainerMenuInterface) this).callSelectRecipeListener((ServerPlayer) player.player ,recipe,craftAll))
|
||||
cir.setReturnValue(RecipeBookMenu.PostPlaceAction.NOTHING);
|
||||
}
|
||||
}
|
||||
+9
-6
@@ -2,18 +2,21 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.AbstractContainerMenuInterface;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractFurnaceMenu;
|
||||
import net.minecraft.world.inventory.RecipeBookMenu;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
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;
|
||||
|
||||
@Mixin(RecipeBookMenu.class)
|
||||
public class RecipeBookMenu_scarpetMixin {
|
||||
@Mixin(AbstractFurnaceMenu.class)
|
||||
public class AbstractFurnaceMenu_scarpetMixin
|
||||
{
|
||||
@Inject(method = "handlePlacement",at = @At("HEAD"), cancellable = true)
|
||||
private void selectRecipeCallback(boolean craftAll, RecipeHolder<?> recipe, ServerPlayer player, CallbackInfo ci) {
|
||||
if(((AbstractContainerMenuInterface) this).callSelectRecipeListener(player,recipe,craftAll))
|
||||
ci.cancel();
|
||||
private void selectRecipeCallback(boolean craftAll, boolean b, RecipeHolder<?> recipe, Inventory player, CallbackInfoReturnable<RecipeBookMenu.PostPlaceAction> cir) {
|
||||
if(((AbstractContainerMenuInterface) this).callSelectRecipeListener((ServerPlayer) player.player ,recipe,craftAll))
|
||||
cir.setReturnValue(RecipeBookMenu.PostPlaceAction.NOTHING);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import carpet.CarpetSettings;
|
||||
import carpet.fakes.LevelInterface;
|
||||
import net.minecraft.world.level.redstone.NeighborUpdater;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.redstone.Orientation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -29,10 +30,10 @@ public class BarrierBlock_updateSuppressionBlockMixin extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, Orientation fromPos, boolean notify) {
|
||||
if (CarpetSettings.updateSuppressionBlock != -1) {
|
||||
if (fromPos.equals(pos.above())) {
|
||||
BlockState stateAbove = level.getBlockState(fromPos);
|
||||
if (true/*fromPos.equals(pos.above())*/) { // todo neighbour updates don't have source
|
||||
BlockState stateAbove = level.getBlockState(pos.above());
|
||||
if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) {
|
||||
level.scheduleTick(pos, this, 1);
|
||||
NeighborUpdater updater = ((LevelInterface)level).getNeighborUpdater();
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.multiplayer.CommonListenerCookie;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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;
|
||||
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public abstract class ClientPacketListener_explosionMixin extends ClientCommonPacketListenerImpl
|
||||
{
|
||||
|
||||
private static Vec3 vec3dmem;
|
||||
private static long tickmem;
|
||||
// For disabling the explosion particles and sounds if explosions are stacking up
|
||||
|
||||
protected ClientPacketListener_explosionMixin(final Minecraft minecraft, final Connection connection, final CommonListenerCookie commonListenerCookie)
|
||||
{
|
||||
super(minecraft, connection, commonListenerCookie);
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "handleExplosion", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/multiplayer/ClientLevel;playLocalSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZ)V"
|
||||
), cancellable = true)
|
||||
private void onHandleExplosion(final ClientboundExplodePacket clientboundExplodePacket, final CallbackInfo ci)
|
||||
{
|
||||
|
||||
if (CarpetSettings.optimizedTNT)
|
||||
{
|
||||
Vec3 vec3d = clientboundExplodePacket.center();
|
||||
long tick = minecraft.level.getGameTime();
|
||||
if (vec3dmem == null || !vec3dmem.equals(vec3d) || tickmem != tick) {
|
||||
vec3dmem = vec3d;
|
||||
tickmem = tick;
|
||||
} else {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.DefaultRedstoneWireEvaluatorInferface;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.redstone.DefaultRedstoneWireEvaluator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(DefaultRedstoneWireEvaluator.class)
|
||||
public abstract class DefaultRedstoneWireEvaluator_redstoneMixin implements DefaultRedstoneWireEvaluatorInferface
|
||||
{
|
||||
@Shadow protected abstract int calculateTargetStrength(final Level level, final BlockPos blockPos);
|
||||
|
||||
@Override
|
||||
public int calculateTargetStrengthCM(final Level level, final BlockPos pos)
|
||||
{
|
||||
return calculateTargetStrength(level, pos);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.world.level.redstone.Orientation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -23,7 +24,7 @@ public class DispenserBlock_qcMixin {
|
||||
target = "Lnet/minecraft/world/level/Level;hasNeighborSignal(Lnet/minecraft/core/BlockPos;)Z"
|
||||
)
|
||||
)
|
||||
private boolean carpet_hasQuasiSignal(Level _level, BlockPos above, BlockState state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean movedByPiston) {
|
||||
private boolean carpet_hasQuasiSignal(Level _level, BlockPos above, BlockState state, Level level, BlockPos pos, Block neighborBlock, Orientation neighborPos, boolean movedByPiston) {
|
||||
return QuasiConnectivity.hasQuasiSignal(level, pos);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(Explosion.class)
|
||||
@Mixin(ServerExplosion.class)
|
||||
public interface ExplosionAccessor {
|
||||
|
||||
@Accessor
|
||||
boolean isFire();
|
||||
ServerLevel getLevel();
|
||||
|
||||
@Accessor
|
||||
Explosion.BlockInteraction getBlockInteraction();
|
||||
|
||||
@Accessor
|
||||
Level getLevel();
|
||||
|
||||
@Accessor
|
||||
RandomSource getRandom();
|
||||
|
||||
@Accessor
|
||||
double getX();
|
||||
|
||||
@Accessor
|
||||
double getY();
|
||||
|
||||
@Accessor
|
||||
double getZ();
|
||||
Vec3 getCenter();
|
||||
|
||||
@Accessor
|
||||
float getRadius();
|
||||
|
||||
@@ -4,11 +4,12 @@ import carpet.helpers.OptimizedExplosion;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.logging.logHelpers.ExplosionLogHelper;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.monster.breeze.Breeze;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -23,75 +24,68 @@ import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = Explosion.class)
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(value = ServerExplosion.class)
|
||||
public abstract class Explosion_optimizedTntMixin
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private ObjectArrayList<BlockPos> toBlow;
|
||||
|
||||
@Shadow @Final private Level level;
|
||||
@Shadow @Final private ServerLevel level;
|
||||
|
||||
@Shadow @Nullable public abstract LivingEntity getIndirectSourceEntity();
|
||||
|
||||
private ExplosionLogHelper eLogger;
|
||||
|
||||
@Inject(method = "explode", at = @At("HEAD"),
|
||||
@Inject(method = "calculateExplodedPositions", at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void onExplosionA(CallbackInfo ci)
|
||||
private void calculateExplodedPositionsCM(final CallbackInfoReturnable<List<BlockPos>> cir)
|
||||
{
|
||||
if (CarpetSettings.optimizedTNT && !level.isClientSide && !(getIndirectSourceEntity() instanceof Breeze))
|
||||
{
|
||||
OptimizedExplosion.doExplosionA((Explosion) (Object) this, eLogger);
|
||||
ci.cancel();
|
||||
cir.setReturnValue(OptimizedExplosion.doExplosionA((Explosion) (Object) this, eLogger));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "finalizeExplosion", at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void onExplosionB(boolean spawnParticles, CallbackInfo ci)
|
||||
@Inject(method = "interactWithBlocks", at = @At("HEAD"))
|
||||
private void interactWithBlocksCM(final List<BlockPos> list, final CallbackInfo ci)
|
||||
{
|
||||
if (eLogger != null)
|
||||
{
|
||||
eLogger.setAffectBlocks( ! toBlow.isEmpty());
|
||||
eLogger.setAffectBlocks( ! list.isEmpty());
|
||||
eLogger.onExplosionDone(this.level.getGameTime());
|
||||
}
|
||||
if (CarpetSettings.explosionNoBlockDamage)
|
||||
{
|
||||
toBlow.clear();
|
||||
list.clear();
|
||||
}
|
||||
if (CarpetSettings.optimizedTNT && !level.isClientSide && !(getIndirectSourceEntity() instanceof Breeze))
|
||||
{
|
||||
OptimizedExplosion.doExplosionB((Explosion) (Object) this, spawnParticles);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
//optional due to Overwrite in Lithium
|
||||
//should kill most checks if no block damage is requested
|
||||
@Redirect(method = "explode", require = 0, at = @At(value = "INVOKE",
|
||||
target ="Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
|
||||
private BlockState noBlockCalcsWithNoBLockDamage(Level world, BlockPos pos)
|
||||
{
|
||||
if (CarpetSettings.explosionNoBlockDamage) return Blocks.BEDROCK.defaultBlockState();
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V",
|
||||
//optional due to Overwrite in Lithium
|
||||
//should kill most checks if no block damage is requested
|
||||
@Redirect(method = "calculateExplodedPositions", require = 0, at = @At(value = "INVOKE",
|
||||
target ="Lnet/minecraft/world/level/ExplosionDamageCalculator;getBlockExplosionResistance(Lnet/minecraft/world/level/Explosion;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/material/FluidState;)Ljava/util/Optional;"))
|
||||
private Optional<Float> noBlockCalcsWithNoBLockDamage(final ExplosionDamageCalculator instance, final Explosion explosion, final BlockGetter blockGetter, final BlockPos blockPos, final BlockState blockState, final FluidState fluidState)
|
||||
{
|
||||
if (CarpetSettings.explosionNoBlockDamage) return Optional.of(Blocks.BEDROCK.getExplosionResistance());
|
||||
return instance.getBlockExplosionResistance(explosion, blockGetter, blockPos, blockState, fluidState);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>",
|
||||
at = @At(value = "RETURN"))
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder soundEvent, CallbackInfo ci)
|
||||
private void onExplostion(ServerLevel world, Entity entity, DamageSource damageSource, final ExplosionDamageCalculator explosionBehavior, final Vec3 vec3, final float power, final boolean createFire, final Explosion.BlockInteraction destructionType, final CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__explosions && ! world.isClientSide)
|
||||
{
|
||||
eLogger = new ExplosionLogHelper(x, y, z, power, createFire, destructionType, level.registryAccess());
|
||||
eLogger = new ExplosionLogHelper(vec3.x, vec3.y, vec3.z, power, createFire, destructionType, level.registryAccess());
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "explode",
|
||||
@Redirect(method = "hurtEntities",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"))
|
||||
private void setVelocityAndUpdateLogging(Entity entity, Vec3 velocity)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -14,66 +12,48 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION_OUTCOME;
|
||||
|
||||
@Mixin(value = Explosion.class, priority = 990)
|
||||
@Mixin(value = ServerExplosion.class, priority = 990)
|
||||
public abstract class Explosion_scarpetEventMixin
|
||||
{
|
||||
@Shadow @Final private Level level;
|
||||
@Shadow @Final private double x;
|
||||
@Shadow @Final private double y;
|
||||
@Shadow @Final private double z;
|
||||
@Shadow @Final private ServerLevel level;
|
||||
@Shadow @Final private Vec3 center;
|
||||
@Shadow @Final private float radius;
|
||||
@Shadow @Final private boolean fire;
|
||||
@Shadow @Final private ObjectArrayList<BlockPos> toBlow;
|
||||
@Shadow @Final private Explosion.BlockInteraction blockInteraction;
|
||||
@Shadow @Final private @Nullable Entity source;
|
||||
|
||||
@Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getIndirectSourceEntity();
|
||||
|
||||
@Shadow public static float getSeenPercent(Vec3 source, Entity entity) {return 0.0f;}
|
||||
private List<Entity> affectedEntities = new ArrayList<>();
|
||||
|
||||
private List<Entity> affectedEntities;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder soundEvent, CallbackInfo ci)
|
||||
@Inject(method = "explode", at = @At("HEAD"))
|
||||
private void explodeCM(CallbackInfo ci)
|
||||
{
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClientSide())
|
||||
{
|
||||
affectedEntities = new ArrayList<>();
|
||||
}
|
||||
affectedEntities.clear();
|
||||
}
|
||||
|
||||
@Redirect(method = "explode", at=@At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Explosion;getSeenPercent(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)F")
|
||||
)
|
||||
private float onExplosion(Vec3 source, Entity entity)
|
||||
@Redirect(method = "hurtEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;onExplosionHit(Lnet/minecraft/world/entity/Entity;)V"))
|
||||
private void onEntityHit(Entity instance, Entity entity)
|
||||
{
|
||||
if (affectedEntities != null)
|
||||
{
|
||||
affectedEntities.add(entity);
|
||||
}
|
||||
return getSeenPercent(source, entity);
|
||||
affectedEntities.add(instance);
|
||||
instance.onExplosionHit(entity);
|
||||
}
|
||||
|
||||
@Inject(method = "finalizeExplosion", at = @At("HEAD"))
|
||||
private void onExplosion(boolean spawnParticles, CallbackInfo ci)
|
||||
@Inject(method = "explode", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerExplosion;hurtEntities()V", shift = At.Shift.AFTER))
|
||||
private void onExplosionDone(CallbackInfo ci, List list)
|
||||
{
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !level.isClientSide())
|
||||
{
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, x, y, z, radius, fire, toBlow, affectedEntities, blockInteraction);
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, center, radius, fire, list, affectedEntities, blockInteraction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class FlowingFluid_liquidDamageDisabledMixin
|
||||
{
|
||||
@Inject(
|
||||
method = "canHoldFluid",
|
||||
method = "canHoldAnyFluid",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/state/BlockState;blocksMotion()Z"
|
||||
),
|
||||
cancellable = true
|
||||
)
|
||||
private void stopBreakingBlock(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid, CallbackInfoReturnable<Boolean> cir)
|
||||
private static void stopBreakingBlock(final BlockState state, final CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.liquidDamageDisabled)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.monster.ElderGuardian;
|
||||
import net.minecraft.world.entity.monster.Guardian;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
@@ -28,7 +26,7 @@ public abstract class Guardian_renewableSpongesMixin extends Monster
|
||||
{
|
||||
ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level());
|
||||
elderGuardian.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
elderGuardian.finalizeSpawn(serverWorld ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, null);
|
||||
elderGuardian.finalizeSpawn(serverWorld ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
elderGuardian.setNoAi(this.isNoAi());
|
||||
|
||||
if (this.hasCustomName())
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.IngredientInterface;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
||||
@Mixin(Ingredient.class)
|
||||
public class Ingredient_scarpetMixin implements IngredientInterface
|
||||
public class Ingredient_scarpetMixin// implements IngredientInterface
|
||||
{
|
||||
@Shadow @Final private Ingredient.Value[] values;
|
||||
|
||||
@Override
|
||||
public List<Collection<ItemStack>> getRecipeStacks()
|
||||
{
|
||||
return Arrays.stream(values).map(Ingredient.Value::getItems).toList();
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,20 @@ package carpet.mixins;
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.script.utils.ShapesRenderer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
|
||||
import com.mojang.blaze3d.framegraph.FramePass;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.FogParameters;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LevelTargetBundle;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
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.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.CallbackInfo;
|
||||
@@ -21,30 +23,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class LevelRenderer_scarpetRenderMixin
|
||||
{
|
||||
@Shadow @Final private LevelTargetBundle targets;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void addRenderers(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers, CallbackInfo ci)
|
||||
{
|
||||
CarpetClient.shapes = new ShapesRenderer(minecraft);
|
||||
}
|
||||
|
||||
@Inject(method = "renderLevel", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/Sheets;translucentCullBlockSheet()Lnet/minecraft/client/renderer/RenderType;", shift = At.Shift.BEFORE
|
||||
//target = "Lnet/minecraft/client/render/RenderLayer;getWaterMask()Lnet/minecraft/client/render/RenderLayer;", shift = At.Shift.AFTER
|
||||
//target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEffectVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.BEFORE
|
||||
//target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER
|
||||
//target = "Lnet/minecraft/client/render/BackgroundRenderer;method_23792()V", shift = At.Shift.AFTER
|
||||
//target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER
|
||||
//target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER // before return
|
||||
))
|
||||
private void renderScarpetThings(final DeltaTracker deltaTracker, final boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
|
||||
@Inject(method = "addParticlesPass", at = @At("RETURN"))
|
||||
private void renderScarpetThingsLate(FrameGraphBuilder frameGraphBuilder, Camera camera, LightTexture lightTexture, float f, FogParameters fogParameters, CallbackInfo ci)
|
||||
{
|
||||
// in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff.
|
||||
// we might actually not need to play with render hooks here.
|
||||
//if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null )
|
||||
if (CarpetClient.shapes != null)
|
||||
{
|
||||
CarpetClient.shapes.render(modelViewMatrix, camera, deltaTracker.getGameTimeDeltaPartialTick(false));
|
||||
FramePass pass = frameGraphBuilder.addPass("scarpet_shapes");
|
||||
targets.main = pass.readsAndWrites(targets.main);
|
||||
pass.executes(() -> CarpetClient.shapes.render(null, camera, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import carpet.fakes.LevelInterface;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.FullChunkStatus;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -28,12 +27,6 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces
|
||||
@Shadow
|
||||
public abstract LevelChunk getChunkAt(BlockPos blockPos_1);
|
||||
|
||||
@Shadow
|
||||
public abstract BlockState getBlockState(BlockPos blockPos_1);
|
||||
|
||||
//@Shadow
|
||||
//public abstract ChunkManager getChunkManager();
|
||||
|
||||
@Shadow
|
||||
public abstract void setBlocksDirty(BlockPos blockPos_1, BlockState s1, BlockState s2);
|
||||
|
||||
@@ -50,8 +43,6 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces
|
||||
|
||||
@Shadow public abstract void updateNeighbourForOutputSignal(BlockPos pos, Block block);
|
||||
|
||||
//@Shadow public abstract boolean setBlockState(BlockPos pos, BlockState state, int flags);
|
||||
|
||||
@Shadow public abstract boolean isDebug();
|
||||
|
||||
/**
|
||||
@@ -86,7 +77,7 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces
|
||||
{
|
||||
BlockState blockState_3 = this.getBlockState(blockPos_1);
|
||||
|
||||
if (blockState_3 != blockState_2 && (blockState_3.getLightBlock((BlockGetter) this, blockPos_1) != blockState_2.getLightBlock((BlockGetter) this, blockPos_1) || blockState_3.getLightEmission() != blockState_2.getLightEmission() || blockState_3.useShapeForLightOcclusion() || blockState_2.useShapeForLightOcclusion()))
|
||||
if (blockState_3 != blockState_2 && (blockState_3.getLightBlock() != blockState_2.getLightBlock() || blockState_3.getLightEmission() != blockState_2.getLightEmission() || blockState_3.useShapeForLightOcclusion() || blockState_2.useShapeForLightOcclusion()))
|
||||
{
|
||||
ProfilerFiller profiler = getProfiler();
|
||||
profiler.push("queueCheckLight");
|
||||
|
||||
@@ -25,8 +25,8 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.91F), expect = 2)
|
||||
private float drag(float original)
|
||||
@ModifyConstant(method = "travelInAir", constant = @Constant(floatValue = 0.91F), expect = 1)
|
||||
private float dragAir(float original)
|
||||
{
|
||||
if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof Player)
|
||||
{
|
||||
@@ -37,7 +37,6 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "getFrictionInfluencedSpeed(F)F", at = @At("HEAD"), cancellable = true)
|
||||
private void flyingAltSpeed(float slipperiness, CallbackInfoReturnable<Float> cir)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
public abstract class MinecraftServer_pingPlayerSampleLimit
|
||||
{
|
||||
|
||||
@ModifyConstant(method = "tickServer", constant = @Constant(intValue = 12), require = 0, allow = 1)
|
||||
@ModifyConstant(method = "buildPlayerStatus", constant = @Constant(intValue = 12), require = 1)
|
||||
private int modifyPlayerSampleLimit(int value)
|
||||
{
|
||||
return CarpetSettings.pingPlayerListLimit;
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantBlockableEve
|
||||
@Override
|
||||
public void reloadAfterReload(RegistryAccess newRegs)
|
||||
{
|
||||
resources.managers().updateRegistryTags();
|
||||
resources.managers().updateStaticRegistryTags();
|
||||
getPlayerList().saveAll();
|
||||
getPlayerList().reloadResources();
|
||||
functionManager.replaceLibrary(this.resources.managers().getFunctionLibrary());
|
||||
|
||||
@@ -36,42 +36,34 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantBlockableE
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "tickServer", at = @At(
|
||||
@Inject(method = "autoSave", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;saveEverything(ZZZ)Z", // save
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
private void startAutosave(final CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Autosave", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickServer", at = @At(
|
||||
@Inject(method = "autoSave", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;saveEverything(ZZZ)Z",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void finishAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
private void finishAutosave(final CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickChildren", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getConnection()Lnet/minecraft/server/network/ServerConnectionListener;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
@Inject(method = "tickConnection", at = @At("HEAD"))
|
||||
private void startNetwork(final CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Network", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickChildren", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/players/PlayerList;tick()V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void finishNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
@Inject(method = "tickConnection", at = @At("RETURN"))
|
||||
private void finishNetwork(final CallbackInfo ci)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package carpet.mixins;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.LevelInterface;
|
||||
import carpet.utils.SpawnReporter;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -12,9 +13,9 @@ 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.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
@@ -24,7 +25,6 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -133,9 +133,9 @@ public class NaturalSpawnerMixin
|
||||
|
||||
@Redirect(method = "getMobForSpawn", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/entity/Entity;"
|
||||
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;"
|
||||
))
|
||||
private static Entity create(EntityType<?> entityType, Level world_1)
|
||||
private static Entity create(final EntityType entityType, final Level world_1, final EntitySpawnReason entitySpawnReason)
|
||||
{
|
||||
if (CarpetSettings.lagFreeSpawning)
|
||||
{
|
||||
@@ -143,11 +143,11 @@ public class NaturalSpawnerMixin
|
||||
if (precookedMobs.containsKey(entityType))
|
||||
//this mob has been <init>'s but not used yet
|
||||
return precookedMobs.get(entityType);
|
||||
Entity e = entityType.create(world_1);
|
||||
Entity e = entityType.create(world_1, entitySpawnReason);
|
||||
precookedMobs.put(entityType, e);
|
||||
return e;
|
||||
}
|
||||
return entityType.create(world_1);
|
||||
return entityType.create(world_1, entitySpawnReason);
|
||||
}
|
||||
|
||||
@Redirect(method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V", at = @At(
|
||||
@@ -176,9 +176,9 @@ public class NaturalSpawnerMixin
|
||||
|
||||
@Redirect(method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Mob;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;"
|
||||
target = "Lnet/minecraft/world/entity/Mob;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;"
|
||||
))
|
||||
private static SpawnGroupData spawnEntity(Mob mobEntity, ServerLevelAccessor serverWorldAccess, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData)
|
||||
private static SpawnGroupData spawnEntity(Mob mobEntity, ServerLevelAccessor serverWorldAccess, DifficultyInstance difficulty, EntitySpawnReason spawnReason, SpawnGroupData entityData)
|
||||
{
|
||||
if (!SpawnReporter.mockSpawns) // WorldAccess
|
||||
return mobEntity.finalizeSpawn(serverWorldAccess, difficulty, spawnReason, entityData);
|
||||
@@ -271,17 +271,13 @@ public class NaturalSpawnerMixin
|
||||
@Inject(method = "spawnForChunk", at = @At("HEAD"))
|
||||
// allows to change mobcaps and captures each category try per dimension before it fails due to full mobcaps.
|
||||
private static void checkSpawns(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info,
|
||||
boolean spawnAnimals, boolean spawnMonsters, boolean shouldSpawnAnimals, CallbackInfo ci)
|
||||
List<MobCategory> list, CallbackInfo ci)
|
||||
{
|
||||
if (SpawnReporter.trackingSpawns())
|
||||
{
|
||||
MobCategory[] var6 = SPAWNING_CATEGORIES;
|
||||
int var7 = var6.length;
|
||||
for (MobCategory entityCategory: list)
|
||||
{
|
||||
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
MobCategory entityCategory = var6[var8];
|
||||
if ((spawnAnimals || !entityCategory.isFriendly()) && (spawnMonsters || entityCategory.isFriendly()) && (shouldSpawnAnimals || !entityCategory.isPersistent()) )
|
||||
{
|
||||
ResourceKey<Level> dim = world.dimension(); // getDimensionType;
|
||||
int newCap = entityCategory.getMaxInstancesPerChunk(); //(int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
|
||||
int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
|
||||
@@ -311,7 +307,6 @@ public class NaturalSpawnerMixin
|
||||
//else
|
||||
//full mobcaps - and key in local_spawns will be missing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.DiggerItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.ToolMaterial;
|
||||
import net.minecraft.world.item.component.Tool;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -18,8 +18,10 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
public class PickaxeItem_missingToolsMixin extends DiggerItem
|
||||
{
|
||||
|
||||
protected PickaxeItem_missingToolsMixin(Tier material, TagKey<Block> tag, Properties settings) {
|
||||
super(material, tag, settings);
|
||||
|
||||
protected PickaxeItem_missingToolsMixin(final ToolMaterial toolMaterial, final TagKey<Block> tagKey, final float f, final float g, final Properties properties)
|
||||
{
|
||||
super(toolMaterial, tagKey, f, g, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@@ -42,9 +43,13 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface
|
||||
Collection<RecipeHolder<?>> typeRecipes = byType.get(type);
|
||||
Registry<Item> regs = registryAccess.registryOrThrow(Registries.ITEM);
|
||||
Item item = regs.get(itemId);
|
||||
if (item == Items.AIR)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
return typeRecipes.stream()
|
||||
.<Recipe<?>>map(RecipeHolder::value)
|
||||
.filter(r -> r.getResultItem(registryAccess).getItem() == item)
|
||||
.filter(r -> r.getResultItem(registryAccess).is(item))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.DefaultRedstoneWireEvaluatorInferface;
|
||||
import carpet.fakes.RedstoneWireBlockInterface;
|
||||
import carpet.helpers.RedstoneWireTurbo;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.world.level.redstone.DefaultRedstoneWireEvaluator;
|
||||
import net.minecraft.world.level.redstone.Orientation;
|
||||
import net.minecraft.world.level.redstone.RedstoneWireEvaluator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
@@ -21,16 +25,15 @@ import net.minecraft.world.level.block.RedStoneWireBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static net.minecraft.world.level.block.RedStoneWireBlock.POWER;
|
||||
|
||||
@Mixin(RedStoneWireBlock.class)
|
||||
public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockInterface {
|
||||
|
||||
@Shadow
|
||||
private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1) { }
|
||||
|
||||
@Shadow
|
||||
private int calculateTargetStrength(Level world, BlockPos pos) { return 0; }
|
||||
private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1, @Nullable final Orientation orientation) { }
|
||||
|
||||
@Override
|
||||
@Accessor("shouldSignal")
|
||||
@@ -40,6 +43,8 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
|
||||
@Accessor("shouldSignal")
|
||||
public abstract boolean getWiresGivePower();
|
||||
|
||||
private RedstoneWireEvaluator legacy = new DefaultRedstoneWireEvaluator((RedStoneWireBlock)(Object) this);
|
||||
|
||||
// =
|
||||
|
||||
private RedstoneWireTurbo wireTurbo = null;
|
||||
@@ -52,20 +57,22 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
|
||||
|
||||
// =
|
||||
|
||||
public void fastUpdate(Level world, BlockPos pos, BlockState state, BlockPos source) {
|
||||
public void fastUpdate(Level world, BlockPos pos, BlockState state, Orientation o) {
|
||||
// [CM] fastRedstoneDust -- update based on carpet rule
|
||||
if (CarpetSettings.fastRedstoneDust) {
|
||||
BlockPos source = null; // todo this probably removes all improvements from the original method
|
||||
// so needs to be evaluated if its worth keeping
|
||||
wireTurbo.updateSurroundingRedstone(world, pos, state, source);
|
||||
return;
|
||||
}
|
||||
updatePowerStrength(world, pos, state);
|
||||
updatePowerStrength(world, pos, state, o);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author theosib, soykaf, gnembon
|
||||
*/
|
||||
@Inject(method = "updatePowerStrength", at = @At("HEAD"), cancellable = true)
|
||||
private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, CallbackInfo cir) {
|
||||
private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, Orientation orientation, CallbackInfo cir) {
|
||||
if (CarpetSettings.fastRedstoneDust) {
|
||||
updateLogicPublic(world, pos, state);
|
||||
cir.cancel();
|
||||
@@ -74,7 +81,7 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
|
||||
|
||||
@Override
|
||||
public BlockState updateLogicPublic(Level world_1, BlockPos blockPos_1, BlockState blockState_1) {
|
||||
int i = this.calculateTargetStrength(world_1, blockPos_1);
|
||||
int i = ((DefaultRedstoneWireEvaluatorInferface)legacy).calculateTargetStrengthCM(world_1, blockPos_1);
|
||||
BlockState blockState = blockState_1;
|
||||
if (blockState_1.getValue(POWER) != i) {
|
||||
blockState_1 = blockState_1.setValue(POWER, i);
|
||||
@@ -107,28 +114,33 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
|
||||
// =
|
||||
|
||||
|
||||
@Redirect(method = "onPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V"))
|
||||
private void redirectOnBlockAddedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1) {
|
||||
fastUpdate(world_1, blockPos_1, blockState_1, null);
|
||||
@Redirect(method = "onPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
|
||||
private void redirectOnBlockAddedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o) {
|
||||
fastUpdate(world_1, blockPos_1, blockState_1, o);
|
||||
}
|
||||
|
||||
@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V"))
|
||||
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1) {
|
||||
fastUpdate(world_1, blockPos_1, blockState_1, null);
|
||||
@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
|
||||
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o) {
|
||||
fastUpdate(world_1, blockPos_1, blockState_1, o);
|
||||
}
|
||||
|
||||
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V"))
|
||||
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
|
||||
//private void red(final RedStoneWireBlock instance, final Level level,
|
||||
// final BlockPos blockPos, final BlockState blockState, final Orientation orientation)
|
||||
private void redirectNeighborUpdateUpdate(
|
||||
RedStoneWireBlock self,
|
||||
Level world_1,
|
||||
BlockPos blockPos_1,
|
||||
BlockState blockState_1,
|
||||
Orientation o,
|
||||
BlockState blockState_2,
|
||||
Level world_2,
|
||||
BlockPos blockPos_2,
|
||||
Block block_1,
|
||||
BlockPos blockPos_3,
|
||||
boolean boolean_1) {
|
||||
fastUpdate(world_1, blockPos_1, blockState_1, blockPos_3);
|
||||
Orientation o2,
|
||||
boolean b
|
||||
)
|
||||
{
|
||||
fastUpdate(world_1, blockPos_1, blockState_1, o);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public abstract class ServerChunkCacheMixin
|
||||
|
||||
@Shadow @Final private DistanceManager distanceManager;
|
||||
|
||||
@Redirect(method = "tickChunks", at = @At(
|
||||
@Redirect(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;JLjava/util/List;)V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/DistanceManager;getNaturalSpawnChunkCount()I"
|
||||
))
|
||||
@@ -54,7 +54,7 @@ public abstract class ServerChunkCacheMixin
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "tickChunks", at = @At("RETURN"))
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;JLjava/util/List;)V", at = @At("RETURN"))
|
||||
private void onFinishSpawnWorldCycle(CallbackInfo ci)
|
||||
{
|
||||
LevelData levelData = this.level.getLevelData(); // levelProperies class
|
||||
|
||||
@@ -19,36 +19,13 @@ public abstract class ServerChunkCache_profilerMixin
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
@Inject(method = "tickChunks", at = @At("HEAD"))
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;JLjava/util/List;)V", at = @At("HEAD"))
|
||||
private void startSpawningSection(CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(level, "Spawning", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickChunks", at = @At(
|
||||
value = "FIELD",
|
||||
target = "net/minecraft/server/level/ServerChunkCache.level:Lnet/minecraft/server/level/ServerLevel;",
|
||||
ordinal = 10
|
||||
))
|
||||
private void skipChunkTicking(CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickChunks", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/server/level/ServerLevel.tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void resumeSpawningSection(CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(level, "Spawning", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickChunks", at = @At("RETURN"))
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;JLjava/util/List;)V", at = @At("RETURN"))
|
||||
private void stopSpawningSection(CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
@@ -56,18 +33,4 @@ public abstract class ServerChunkCache_profilerMixin
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
}
|
||||
|
||||
//@Redirect(method = "tick", at = @At(
|
||||
// value = "INVOKE",
|
||||
// target = "Lnet/minecraft/server/level/DistanceManager;purgeStaleTickets()V"
|
||||
//))
|
||||
//private void pauseTicketSystem(DistanceManager distanceManager)
|
||||
//{
|
||||
// pausing expiry of tickets
|
||||
// that will prevent also chunks from unloading, so require a deep frozen state
|
||||
//ServerTickRateManager trm = ((MinecraftServerInterface) level.getServer()).getTickRateManager();
|
||||
//if (!trm.runsNormally() && trm.deeplyFrozen()) return;
|
||||
//distanceManager.purgeStaleTickets();
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatCommandPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -51,9 +52,14 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
{
|
||||
@Shadow public ServerPlayer player;
|
||||
|
||||
@Inject(method = "handlePlayerInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;setPlayerInput(FFZZ)V"))
|
||||
@Inject(method = "handlePlayerInput", at = @At("HEAD"))
|
||||
private void checkMoves(ServerboundPlayerInputPacket p, CallbackInfo ci)
|
||||
{
|
||||
// todo this may not ride on the right thread moment, so needs to be checked
|
||||
|
||||
if (!((EntityInterface)player.getVehicle()).isPermanentVehicle()) // won't since that method makes sure its not null
|
||||
player.setShiftKeyDown(p.isShiftKeyDown());
|
||||
|
||||
if (PLAYER_RIDES.isNeeded() && (p.getXxa() != 0.0F || p.getZza() != 0.0F || p.isJumping() || p.isShiftKeyDown()))
|
||||
{
|
||||
PLAYER_RIDES.onMountControls(player, p.getXxa(), p.getZza(), p.isJumping(), p.isShiftKeyDown());
|
||||
@@ -246,7 +252,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
{
|
||||
if (PLAYER_CHOOSES_RECIPE.isNeeded())
|
||||
{
|
||||
if(PLAYER_CHOOSES_RECIPE.onRecipeSelected(player, packet.getRecipe(), packet.isShiftDown())) ci.cancel();
|
||||
if(PLAYER_CHOOSES_RECIPE.onRecipeSelected(player, packet.getRecipe(), packet.isUseMaxItems())) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.WritableLevelData;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -31,7 +32,6 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
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 java.util.function.Supplier;
|
||||
@@ -65,8 +65,8 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
|
||||
return getGameRules().getBoolean(rule) ? Explosion.BlockInteraction.DESTROY_WITH_DECAY : Explosion.BlockInteraction.DESTROY;
|
||||
}
|
||||
|
||||
@Inject(method = "explode", at = @At("HEAD"))
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder<SoundEvent> soundEvent, CallbackInfoReturnable<Explosion> cir)
|
||||
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
||||
private void handleExplosion(final Entity entity, final DamageSource damageSource, final ExplosionDamageCalculator explosionDamageCalculator, final double x, final double y, final double z, final float g, final boolean bl, final ExplosionInteraction explosionInteraction, final ParticleOptions particleOptions, final ParticleOptions particleOptions2, final Holder<SoundEvent> holder, final CallbackInfo ci)
|
||||
{
|
||||
if (EXPLOSION.isNeeded()) {
|
||||
Explosion.BlockInteraction var10000 = switch (explosionInteraction) {
|
||||
@@ -74,10 +74,12 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
|
||||
case BLOCK -> this.getCMDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY);
|
||||
case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getCMDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP;
|
||||
case TNT -> this.getCMDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
|
||||
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
default -> throw new IncompatibleClassChangeError();
|
||||
};
|
||||
|
||||
EXPLOSION.onExplosion((ServerLevel) (Object) this, entity, null, d, e, f, g, bl, null, null, var10000);
|
||||
boolean cancelled = EXPLOSION.onExplosion((ServerLevel) (Object) this, entity, null, new Vec3(x, y, z), g, bl, null, null, var10000);
|
||||
if (cancelled) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package carpet.mixins;
|
||||
import carpet.helpers.BlockRotator;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -19,13 +19,13 @@ public class ServerPlayerGameMode_cactusMixin
|
||||
|
||||
@Redirect(method = "useItemOn", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/state/BlockState;useItemOn(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/ItemInteractionResult;"
|
||||
target = "Lnet/minecraft/world/level/block/state/BlockState;useItemOn(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;"
|
||||
))
|
||||
private ItemInteractionResult activateWithOptionalCactus(final BlockState blockState, final ItemStack itemStack, final Level world_1, final Player playerEntity_1, final InteractionHand hand_1, final BlockHitResult blockHitResult_1)
|
||||
private InteractionResult activateWithOptionalCactus(final BlockState blockState, final ItemStack itemStack, final Level world_1, final Player playerEntity_1, final InteractionHand hand_1, final BlockHitResult blockHitResult_1)
|
||||
{
|
||||
boolean flipped = BlockRotator.flipBlockWithCactus(blockState, world_1, playerEntity_1, hand_1, blockHitResult_1);
|
||||
if (flipped)
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
return blockState.useItemOn(itemStack, world_1, playerEntity_1, hand_1, blockHitResult_1);
|
||||
}
|
||||
|
||||
@@ -83,16 +83,6 @@ public abstract class ServerPlayer_scarpetEventMixin extends Player implements S
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "setPlayerInput", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;setShiftKeyDown(Z)V"
|
||||
))
|
||||
private void setSneakingConditionally(ServerPlayer serverPlayerEntity, boolean sneaking)
|
||||
{
|
||||
if (!((EntityInterface)serverPlayerEntity.getVehicle()).isPermanentVehicle()) // won't since that method makes sure its not null
|
||||
serverPlayerEntity.setShiftKeyDown(sneaking);
|
||||
}
|
||||
|
||||
private Vec3 previousLocation;
|
||||
private ResourceKey<Level> previousDimension;
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package carpet.mixins;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.client.model.ShulkerModel;
|
||||
|
||||
@Mixin(net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer.class)
|
||||
public interface ShulkerBoxAccessMixin {
|
||||
@Accessor("model")
|
||||
ShulkerModel getModel();
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.server.commands.SummonCommand;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.entity.animal.horse.SkeletonHorse;
|
||||
@@ -31,7 +32,7 @@ public class SummonCommand_lightningMixin
|
||||
DifficultyInstance localDifficulty_1 = world.getCurrentDifficultyAt(at);
|
||||
boolean boolean_2 = world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && world.random.nextDouble() < (double)localDifficulty_1.getEffectiveDifficulty() * 0.01D;
|
||||
if (boolean_2) {
|
||||
SkeletonHorse skeletonHorseEntity_1 = EntityType.SKELETON_HORSE.create(world);
|
||||
SkeletonHorse skeletonHorseEntity_1 = EntityType.SKELETON_HORSE.create(world, EntitySpawnReason.EVENT);
|
||||
skeletonHorseEntity_1.setTrap(true);
|
||||
skeletonHorseEntity_1.setAge(0);
|
||||
skeletonHorseEntity_1.setPos(entity.getX(), entity.getY(), entity.getZ());
|
||||
|
||||
@@ -77,7 +77,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, current, ClientInformation.createDefault(), false);
|
||||
instance.fixStartingPosition = () -> instance.moveTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, new CommonListenerCookie(current, 0, instance.clientInformation(), false));
|
||||
instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch, true);
|
||||
instance.setHealth(20.0F);
|
||||
instance.unsetRemoved();
|
||||
instance.getAttribute(Attributes.STEP_HEIGHT).setBaseValue(0.6F);
|
||||
@@ -215,7 +215,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity changeDimension(DimensionTransition serverLevel)
|
||||
public Player changeDimension(DimensionTransition serverLevel)
|
||||
{
|
||||
super.changeDimension(serverLevel);
|
||||
if (wonGame) {
|
||||
|
||||
@@ -1051,11 +1051,11 @@ public class CarpetEventServer
|
||||
public static final Event EXPLOSION_OUTCOME = new Event("explosion_outcome", 8, true)
|
||||
{
|
||||
@Override
|
||||
public void onExplosion(ServerLevel world, Entity e, Supplier<LivingEntity> attacker, double x, double y, double z, float power, boolean createFire, List<BlockPos> affectedBlocks, List<Entity> affectedEntities, Explosion.BlockInteraction type)
|
||||
public boolean onExplosion(ServerLevel world, Entity e, Supplier<LivingEntity> attacker, Vec3 center, float power, boolean createFire, List<BlockPos> affectedBlocks, List<Entity> affectedEntities, Explosion.BlockInteraction type)
|
||||
{
|
||||
handler.call(
|
||||
() -> Arrays.asList(
|
||||
ListValue.fromTriple(x, y, z),
|
||||
ValueConversions.of(center),
|
||||
NumericValue.of(power),
|
||||
EntityValue.of(e),
|
||||
EntityValue.of(attacker != null ? attacker.get() : Event.getExplosionCausingEntity(e)),
|
||||
@@ -1067,6 +1067,7 @@ public class CarpetEventServer
|
||||
ListValue.wrap(affectedEntities.stream().map(EntityValue::of))
|
||||
), () -> world.getServer().createCommandSourceStack().withLevel(world)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1074,11 +1075,11 @@ public class CarpetEventServer
|
||||
public static final Event EXPLOSION = new Event("explosion", 6, true)
|
||||
{
|
||||
@Override
|
||||
public void onExplosion(ServerLevel world, Entity e, Supplier<LivingEntity> attacker, double x, double y, double z, float power, boolean createFire, List<BlockPos> affectedBlocks, List<Entity> affectedEntities, Explosion.BlockInteraction type)
|
||||
public boolean onExplosion(ServerLevel world, Entity e, Supplier<LivingEntity> attacker, Vec3 center, float power, boolean createFire, List<BlockPos> affectedBlocks, List<Entity> affectedEntities, Explosion.BlockInteraction type)
|
||||
{
|
||||
handler.call(
|
||||
return handler.call(
|
||||
() -> Arrays.asList(
|
||||
ListValue.fromTriple(x, y, z),
|
||||
ValueConversions.of(center),
|
||||
NumericValue.of(power),
|
||||
EntityValue.of(e),
|
||||
EntityValue.of(attacker != null ? attacker.get() : Event.getExplosionCausingEntity(e)),
|
||||
@@ -1306,8 +1307,9 @@ public class CarpetEventServer
|
||||
{
|
||||
}
|
||||
|
||||
public void onExplosion(ServerLevel world, Entity e, Supplier<LivingEntity> attacker, double x, double y, double z, float power, boolean createFire, List<BlockPos> affectedBlocks, List<Entity> affectedEntities, Explosion.BlockInteraction type)
|
||||
public boolean onExplosion(ServerLevel world, Entity e, Supplier<LivingEntity> attacker, Vec3 center, float power, boolean createFire, List<BlockPos> affectedBlocks, List<Entity> affectedEntities, Explosion.BlockInteraction type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onWorldEvent(ServerLevel world, BlockPos pos)
|
||||
|
||||
@@ -33,9 +33,9 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySelector;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -142,7 +142,7 @@ public class Entities
|
||||
Vec3 vec3d = position.vec;
|
||||
|
||||
ServerLevel serverWorld = cc.level();
|
||||
Entity entity = EntityType.loadEntityRecursive(tag, serverWorld, e -> {
|
||||
Entity entity = EntityType.loadEntityRecursive(tag, serverWorld, EntitySpawnReason.COMMAND, e -> {
|
||||
e.moveTo(vec3d.x, vec3d.y, vec3d.z, e.getYRot(), e.getXRot());
|
||||
return e;
|
||||
});
|
||||
@@ -150,9 +150,9 @@ public class Entities
|
||||
{
|
||||
return Value.NULL;
|
||||
}
|
||||
if (!hasTag && entity instanceof final Mob mob)
|
||||
if (!hasTag && entity instanceof Mob mob)
|
||||
{
|
||||
mob.finalizeSpawn(serverWorld, serverWorld.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, null);
|
||||
mob.finalizeSpawn(serverWorld, serverWorld.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, null);
|
||||
}
|
||||
if (!serverWorld.tryAddFreshEntityWithPassengers(entity))
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ import carpet.script.value.Value;
|
||||
import carpet.script.value.ValueConversions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -44,6 +43,7 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
import net.minecraft.world.item.crafting.PlacementInfo;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
||||
@@ -83,12 +83,12 @@ public class Inventories
|
||||
Registry<Item> blocks = cc.registry(Registries.ITEM);
|
||||
if (lv.isEmpty())
|
||||
{
|
||||
return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of));
|
||||
return ListValue.wrap(blocks.getTags().map(ValueConversions::of));
|
||||
}
|
||||
Item item = NBTSerializableValue.parseItem(lv.get(0).getString(), cc.registryAccess()).getItem();
|
||||
if (lv.size() == 1)
|
||||
{
|
||||
return ListValue.wrap(blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == item))).map(e -> ValueConversions.of(e.getFirst())));
|
||||
return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == item))).map(ValueConversions::of));
|
||||
}
|
||||
String tag = lv.get(1).getString();
|
||||
Optional<HolderSet.Named<Item>> tagSet = blocks.getTag(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag)));
|
||||
@@ -124,22 +124,20 @@ public class Inventories
|
||||
{
|
||||
ItemStack result = recipe.getResultItem(regs);
|
||||
List<Value> ingredientValue = new ArrayList<>();
|
||||
recipe.getIngredients().forEach(ingredient -> {
|
||||
// I am flattening ingredient lists per slot.
|
||||
// consider recipe_data('wooden_sword','crafting') and ('iron_nugget', 'blasting') and notice difference
|
||||
// in depths of lists.
|
||||
List<Collection<ItemStack>> stacks = Vanilla.Ingredient_getRecipeStacks(ingredient);
|
||||
if (stacks.isEmpty())
|
||||
recipe.placementInfo().slotInfo().forEach(ingredient -> {
|
||||
if (ingredient.isEmpty())
|
||||
{
|
||||
ingredientValue.add(Value.NULL);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Value> alternatives = new ArrayList<>();
|
||||
stacks.forEach(col -> col.stream().map(is -> ValueConversions.of(is, regs)).forEach(alternatives::add));
|
||||
ingredientValue.add(ListValue.wrap(alternatives));
|
||||
}
|
||||
PlacementInfo.SlotInfo value = ingredient.get();
|
||||
int position = value.placerOutputPosition();
|
||||
|
||||
List<Value> alternatives = new ArrayList<>();
|
||||
value.possibleItems().stream().map(is -> ValueConversions.of(is, regs)).forEach(alternatives::add);
|
||||
ingredientValue.add(ListValue.wrap(alternatives));
|
||||
});
|
||||
|
||||
Value recipeSpec;
|
||||
if (recipe instanceof ShapedRecipe shapedRecipe)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -50,6 +51,7 @@ import net.minecraft.server.level.Ticket;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
@@ -695,7 +697,7 @@ public class WorldAccess
|
||||
expression.addContextFunction("update", -1, (c, t, lv) ->
|
||||
booleanStateTest(c, "update", lv, (s, p) ->
|
||||
{
|
||||
((CarpetContext) c).level().neighborChanged(p, s.getBlock(), p);
|
||||
((CarpetContext) c).level().neighborChanged(p, s.getBlock(), null);
|
||||
return true;
|
||||
}));
|
||||
|
||||
@@ -1071,10 +1073,9 @@ public class WorldAccess
|
||||
}
|
||||
}
|
||||
LivingEntity theAttacker = attacker;
|
||||
float thePowah = powah;
|
||||
|
||||
// copy of ServerWorld.createExplosion #TRACK#
|
||||
Explosion explosion = new Explosion(cc.level(), source, null, null, pos.x, pos.y, pos.z, powah, createFire, mode, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE)
|
||||
ServerExplosion explosion = new ServerExplosion(cc.level(), source, null, null, pos, powah, createFire, mode)
|
||||
{
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -1085,16 +1086,11 @@ public class WorldAccess
|
||||
}
|
||||
};
|
||||
explosion.explode();
|
||||
explosion.finalizeExplosion(false);
|
||||
if (mode == Explosion.BlockInteraction.KEEP)
|
||||
{
|
||||
explosion.clearToBlow();
|
||||
}
|
||||
Explosion.BlockInteraction finalMode = mode;
|
||||
ParticleOptions explosionParticle = explosion.isSmall() ? ParticleTypes.EXPLOSION : ParticleTypes.EXPLOSION_EMITTER;
|
||||
cc.level().players().forEach(spe -> {
|
||||
if (spe.distanceToSqr(pos) < 4096.0D)
|
||||
{
|
||||
spe.connection.send(new ClientboundExplodePacket(pos.x, pos.y, pos.z, thePowah, explosion.getToBlow(), explosion.getHitPlayers().get(spe), finalMode, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE));
|
||||
spe.connection.send(new ClientboundExplodePacket(pos, Optional.ofNullable(explosion.getHitPlayers().get(spe)), explosionParticle, SoundEvents.GENERIC_EXPLODE));
|
||||
}
|
||||
});
|
||||
return Value.TRUE;
|
||||
@@ -1239,13 +1235,13 @@ public class WorldAccess
|
||||
Registry<Block> blocks = cc.registry(Registries.BLOCK);
|
||||
if (lv.isEmpty())
|
||||
{
|
||||
return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of));
|
||||
return ListValue.wrap(blocks.getTags().map(ValueConversions::of));
|
||||
}
|
||||
BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true);
|
||||
if (blockLocator.offset == lv.size())
|
||||
{
|
||||
Block target = blockLocator.block.getBlockState().getBlock();
|
||||
return ListValue.wrap(blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == target))).map(e -> ValueConversions.of(e.getFirst())));
|
||||
return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == target))).map(ValueConversions::of));
|
||||
}
|
||||
String tag = lv.get(blockLocator.offset).getString();
|
||||
Optional<HolderSet.Named<Block>> tagSet = blocks.getTag(TagKey.create(Registries.BLOCK, InputValidator.identifierOf(tag)));
|
||||
|
||||
@@ -7,7 +7,6 @@ import carpet.fakes.BlockStateArgumentInterface;
|
||||
import carpet.fakes.ChunkTicketManagerInterface;
|
||||
import carpet.fakes.CommandDispatcherInterface;
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.IngredientInterface;
|
||||
import carpet.fakes.InventoryBearerInterface;
|
||||
import carpet.fakes.ItemEntityInterface;
|
||||
import carpet.fakes.LivingEntityInterface;
|
||||
@@ -108,11 +107,6 @@ public class Vanilla
|
||||
return Map.of(); //return ((ThreadedAnvilChunkStorageInterface) chunkMap).regenerateChunkRegion(requestedChunks);
|
||||
}
|
||||
|
||||
public static List<Collection<ItemStack>> Ingredient_getRecipeStacks(Ingredient ingredient)
|
||||
{
|
||||
return ((IngredientInterface) (Object) ingredient).getRecipeStacks();
|
||||
}
|
||||
|
||||
public static List<Recipe<?>> RecipeManager_getAllMatching(RecipeManager recipeManager, RecipeType<?> type, ResourceLocation output, RegistryAccess registryAccess)
|
||||
{
|
||||
return ((RecipeManagerInterface) recipeManager).getAllMatching(type, output, registryAccess);
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package carpet.script.external;
|
||||
|
||||
import carpet.mixins.ShulkerBoxAccessMixin;
|
||||
import net.minecraft.client.model.ShulkerModel;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||
|
||||
public class VanillaClient
|
||||
{
|
||||
public static ShulkerModel<?> ShulkerBoxRenderer_model(BlockEntityRenderer<ShulkerBoxBlockEntity> shulkerBoxRenderer) {
|
||||
return ((ShulkerBoxAccessMixin)shulkerBoxRenderer).getModel();
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class BiomeInfo
|
||||
{
|
||||
public static final Map<String, BiFunction<ServerLevel, Biome, Value>> biomeFeatures = new HashMap<>()
|
||||
{{
|
||||
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registries.BIOME).getTags().filter(p -> p.getSecond().stream().anyMatch(h -> h.value() == b)).map(p -> p.getFirst().location()).map(ValueConversions::of)));
|
||||
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registries.BIOME).getTags().filter(p -> p.stream().anyMatch(h -> h.value() == b)).map(ValueConversions::of)));
|
||||
put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature()));
|
||||
put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor()));
|
||||
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
|
||||
@@ -31,7 +31,7 @@ public class BiomeInfo
|
||||
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterColor()));
|
||||
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterFogColor()));
|
||||
put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall()));
|
||||
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0)).name().toLowerCase(Locale.ROOT)));
|
||||
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT)));
|
||||
put("features", (w, b) -> {
|
||||
Registry<ConfiguredFeature<?, ?>> registry = w.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
|
||||
return ListValue.wrap(
|
||||
|
||||
@@ -304,8 +304,7 @@ public class FeatureGenerator
|
||||
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
new JigsawStructure(new Structure.StructureSettings(l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
@@ -334,7 +333,7 @@ public class FeatureGenerator
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
@@ -363,7 +362,7 @@ public class FeatureGenerator
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
@@ -392,7 +391,7 @@ public class FeatureGenerator
|
||||
|
||||
return spawnCustomStructure(
|
||||
new JigsawStructure(new Structure.StructureSettings(
|
||||
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
TerrainAdjustment.NONE
|
||||
|
||||
@@ -2,7 +2,6 @@ package carpet.script.utils;
|
||||
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.script.external.Carpet;
|
||||
import carpet.script.external.VanillaClient;
|
||||
import carpet.script.utils.shapes.ShapeDirection;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -12,7 +11,6 @@ import com.mojang.blaze3d.vertex.ByteBufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
|
||||
import com.mojang.math.Axis;
|
||||
@@ -26,34 +24,27 @@ import java.util.function.BiFunction;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.model.ShulkerModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -160,7 +151,6 @@ public class ShapesRenderer
|
||||
Matrix4fStack matrixStack = RenderSystem.getModelViewStack();
|
||||
matrixStack.pushMatrix();
|
||||
matrixStack.mul(matrices.last().pose());
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
// lines
|
||||
RenderSystem.lineWidth(0.5F);
|
||||
@@ -180,7 +170,6 @@ public class ShapesRenderer
|
||||
});
|
||||
RenderSystem.lineWidth(1.0F);
|
||||
matrixStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
}
|
||||
if (!labels.isEmpty())
|
||||
@@ -439,15 +428,8 @@ public class ShapesRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
if (BlockEntity instanceof ShulkerBoxBlockEntity sbBlockEntity)
|
||||
if (BlockEntity != null)
|
||||
{
|
||||
sbrender(sbBlockEntity, partialTick,
|
||||
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BlockEntity != null)
|
||||
{
|
||||
BlockEntityRenderer<BlockEntity> blockEntityRenderer = client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity);
|
||||
if (blockEntityRenderer != null)
|
||||
{
|
||||
@@ -455,7 +437,6 @@ public class ShapesRenderer
|
||||
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -480,44 +461,6 @@ public class ShapesRenderer
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// copy and modifiy a bit from net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer.render
|
||||
public void sbrender(ShulkerBoxBlockEntity shulkerBoxBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j)
|
||||
{
|
||||
Direction direction = Direction.UP;
|
||||
if (shulkerBoxBlockEntity.hasLevel())
|
||||
{
|
||||
BlockState blockState = shulkerBoxBlockEntity.getBlockState();
|
||||
if (blockState.getBlock() instanceof ShulkerBoxBlock)
|
||||
{
|
||||
direction = blockState.getValue(ShulkerBoxBlock.FACING);
|
||||
}
|
||||
}
|
||||
DyeColor dyeColor = shulkerBoxBlockEntity.getColor();
|
||||
Material material;
|
||||
if (dyeColor == null)
|
||||
{
|
||||
material = Sheets.DEFAULT_SHULKER_TEXTURE_LOCATION;
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Sheets.SHULKER_TEXTURE_LOCATION.get(dyeColor.getId());
|
||||
}
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0.5, 0.5, 0.5);
|
||||
poseStack.scale(0.9995F, 0.9995F, 0.9995F);
|
||||
poseStack.mulPose(direction.getRotation());
|
||||
poseStack.scale(1.0F, -1.0F, -1.0F);
|
||||
poseStack.translate(0.0, -1.0, 0.0);
|
||||
ShulkerModel<?> model = VanillaClient.ShulkerBoxRenderer_model(client.getBlockEntityRenderDispatcher().getRenderer(shulkerBoxBlockEntity));
|
||||
ModelPart modelPart = model.getLid();
|
||||
modelPart.setPos(0.0F, 24.0F - shulkerBoxBlockEntity.getProgress(f) * 0.5F * 16.0F, 0.0F);
|
||||
modelPart.yRot = 270.0F * shulkerBoxBlockEntity.getProgress(f) * (float) (Math.PI / 180.0);
|
||||
VertexConsumer vertexConsumer = material.buffer(multiBufferSource, RenderType::entityCutoutNoCull);
|
||||
model.renderToBuffer(poseStack, vertexConsumer, i, j, 0xffffffff);
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class SystemInfo
|
||||
put("world_gamerules", c -> {
|
||||
Map<Value, Value> rules = new HashMap<>();
|
||||
GameRules gameRules = c.level().getGameRules();
|
||||
GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor()
|
||||
gameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor()
|
||||
{
|
||||
@Override
|
||||
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type)
|
||||
|
||||
@@ -25,8 +25,8 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetHeldSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -457,7 +457,7 @@ public class EntityValue extends Value
|
||||
put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new)));
|
||||
put("entity_tags", (e, a) -> {
|
||||
EntityType<?> type = e.getType();
|
||||
return ListValue.wrap(e.getServer().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.getSecond().stream().anyMatch(h -> h.value() == type)).map(entry -> ValueConversions.of(entry.getFirst())));
|
||||
return ListValue.wrap(e.getServer().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.stream().anyMatch(h -> h.value() == type)).map(entry -> ValueConversions.of(entry)));
|
||||
});
|
||||
// deprecated
|
||||
put("has_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString())));
|
||||
@@ -1019,7 +1019,7 @@ public class EntityValue extends Value
|
||||
if (e instanceof ServerPlayer player)
|
||||
{
|
||||
int slot = NumericValue.asNumber(v).getInt();
|
||||
player.connection.send(new ClientboundSetCarriedItemPacket(slot));
|
||||
player.connection.send(new ClientboundSetHeldSlotPacket(slot));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -189,6 +190,11 @@ public class ValueConversions
|
||||
return of(tagKey.location());
|
||||
}
|
||||
|
||||
public static Value of(HolderSet.Named<?> tagKey)
|
||||
{
|
||||
return of(tagKey.key().location());
|
||||
}
|
||||
|
||||
public static Value of(@Nullable ResourceLocation id)
|
||||
{
|
||||
if (id == null) // should be Value.NULL
|
||||
|
||||
@@ -9,8 +9,8 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.entity.ai.goal.RandomStrollGoal;
|
||||
import net.minecraft.world.entity.ai.util.DefaultRandomPos;
|
||||
@@ -75,7 +75,7 @@ public class BlockInfo
|
||||
private static Component wander_chances(BlockPos pos, ServerLevel worldIn)
|
||||
{
|
||||
PathfinderMob creature = new ZombifiedPiglin(EntityType.ZOMBIFIED_PIGLIN, worldIn);
|
||||
creature.finalizeSpawn(worldIn, worldIn.getCurrentDifficultyAt(pos), MobSpawnType.NATURAL, null);
|
||||
creature.finalizeSpawn(worldIn, worldIn.getCurrentDifficultyAt(pos), EntitySpawnReason.NATURAL, null);
|
||||
creature.moveTo(pos, 0.0F, 0.0F);
|
||||
RandomStrollGoal wander = new RandomStrollGoal(creature, 0.8D);
|
||||
int success = 0;
|
||||
|
||||
@@ -6,10 +6,10 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnPlacements;
|
||||
import net.minecraft.world.entity.ambient.AmbientCreature;
|
||||
import net.minecraft.world.entity.animal.WaterAnimal;
|
||||
@@ -179,8 +179,8 @@ public class PerimeterDiagnostics
|
||||
if (SpawnPlacements.isSpawnPositionOk(sle.type, worldServer, pos))
|
||||
{
|
||||
el.moveTo(pos.getX() + 0.5F, pos.getY(), pos.getZ()+0.5F, 0.0F, 0.0F);
|
||||
return el.checkSpawnObstruction(worldServer) && el.checkSpawnRules(worldServer, MobSpawnType.NATURAL) &&
|
||||
SpawnPlacements.checkSpawnRules(el.getType(),(ServerLevel)el.getCommandSenderWorld(), MobSpawnType.NATURAL, el.blockPosition(), el.getCommandSenderWorld().random) &&
|
||||
return el.checkSpawnObstruction(worldServer) && el.checkSpawnRules(worldServer, EntitySpawnReason.NATURAL) &&
|
||||
SpawnPlacements.checkSpawnRules(el.getType(),(ServerLevel)el.getCommandSenderWorld(), EntitySpawnReason.NATURAL, el.blockPosition(), el.getCommandSenderWorld().random) &&
|
||||
worldServer.noCollision(el); // check collision rules once they stop fiddling with them after 1.14.1
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -13,11 +13,11 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnPlacements;
|
||||
import net.minecraft.world.entity.animal.Ocelot;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
@@ -421,7 +421,7 @@ public class SpawnReporter
|
||||
Mob mob;
|
||||
try
|
||||
{
|
||||
mob = (Mob) spawnEntry.type.create(worldIn);
|
||||
mob = (Mob) spawnEntry.type.create(worldIn, EntitySpawnReason.NATURAL);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -443,9 +443,9 @@ public class SpawnReporter
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
if (
|
||||
SpawnPlacements.checkSpawnRules(etype,worldIn, MobSpawnType.NATURAL, pos, worldIn.random) &&
|
||||
SpawnPlacements.checkSpawnRules(etype,worldIn, EntitySpawnReason.NATURAL, pos, worldIn.random) &&
|
||||
SpawnPlacements.isSpawnPositionOk(etype, worldIn, pos) &&
|
||||
mob.checkSpawnRules(worldIn, MobSpawnType.NATURAL)
|
||||
mob.checkSpawnRules(worldIn, EntitySpawnReason.NATURAL)
|
||||
// && mob.canSpawn(worldIn) // entity collisions // mostly - except ocelots
|
||||
)
|
||||
{
|
||||
@@ -459,7 +459,7 @@ public class SpawnReporter
|
||||
willSpawn += 1;
|
||||
}
|
||||
}
|
||||
mob.finalizeSpawn(worldIn, worldIn.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.NATURAL, null);
|
||||
mob.finalizeSpawn(worldIn, worldIn.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.NATURAL, null);
|
||||
// the code invokes onInitialSpawn after getCanSpawHere
|
||||
fits = fits && worldIn.noCollision(mob);
|
||||
|
||||
@@ -467,7 +467,7 @@ public class SpawnReporter
|
||||
|
||||
try
|
||||
{
|
||||
mob = (Mob) spawnEntry.type.create(worldIn);
|
||||
mob = (Mob) spawnEntry.type.create(worldIn, EntitySpawnReason.NATURAL);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@ accessWidener v1 named
|
||||
|
||||
accessible class net/minecraft/server/level/ChunkMap$DistanceManager
|
||||
accessible class net/minecraft/server/level/ThreadedLevelLightEngine$TaskType
|
||||
accessible class net/minecraft/world/item/crafting/Ingredient$Value
|
||||
accessible class net/minecraft/world/level/lighting/BlockLightSectionStorage$BlockDataLayerStorageMap
|
||||
accessible class net/minecraft/world/level/border/WorldBorder$BorderExtent
|
||||
accessible class net/minecraft/world/level/border/WorldBorder$StaticBorderExtent
|
||||
@@ -12,6 +11,7 @@ accessible class net/minecraft/world/level/block/entity/SculkSensorBlockEntity$V
|
||||
|
||||
#TODO fields and methods should be fetched via interfaces unless there is a good reason not to
|
||||
accessible method net/minecraft/world/level/border/WorldBorder getListeners ()Ljava/util/List;
|
||||
accessible method net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator calculateTargetStrength (Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)I
|
||||
|
||||
accessible method net/minecraft/server/level/DistanceManager purgeStaleTickets ()V
|
||||
#cause I don't want to deal with the interfaces until stuff is stable
|
||||
|
||||
@@ -139,7 +139,8 @@
|
||||
"MerchantResultSlot_scarpetEventMixin",
|
||||
"AbstractContainerMenu_scarpetMixin",
|
||||
"AbstractContainerMenuSubclasses_scarpetMixin",
|
||||
"RecipeBookMenu_scarpetMixin",
|
||||
"AbstractCraftingMenu_scarpetMixin",
|
||||
"AbstractFurnaceMenu_scarpetMixin",
|
||||
"DistanceManager_scarpetMixin",
|
||||
"PoiRecord_scarpetMixin",
|
||||
"ServerLevel_scarpetMixin",
|
||||
@@ -150,7 +151,6 @@
|
||||
"CommandDispatcher_scarpetCommandsMixin",
|
||||
|
||||
"RecipeManager_scarpetMixin",
|
||||
"Ingredient_scarpetMixin",
|
||||
"BlockInput_scarpetMixin",
|
||||
"BlockPredicate_scarpetMixin",
|
||||
"TagPredicate_scarpetMixin",
|
||||
@@ -180,19 +180,21 @@
|
||||
"ChestBlock_customStickyMixin",
|
||||
"PistonStructureResolver_customStickyMixin",
|
||||
|
||||
"DefaultRedstoneWireEvaluator_redstoneMixin",
|
||||
|
||||
"CustomPacketPayload_networkStuffMixin",
|
||||
"ServerGamePacketListenerimpl_connectionMixin"
|
||||
|
||||
],
|
||||
"client": [
|
||||
"Minecraft_tickMixin",
|
||||
"ShulkerBoxAccessMixin",
|
||||
"MinecraftMixin",
|
||||
"Gui_tablistMixin",
|
||||
"PlayerTabOverlayMixin",
|
||||
"PistonHeadRenderer_movableBEMixin",
|
||||
"StructureBlockRenderer_mixin",
|
||||
"ClientPacketListener_clientCommandMixin",
|
||||
"ClientPacketListener_explosionMixin",
|
||||
"LevelRenderer_fogOffMixin",
|
||||
"LevelRenderer_creativeNoClipMixin",
|
||||
"ClientPacketListener_customPacketsMixin",
|
||||
|
||||
Reference in new issue
Block a user