23w17a
This commit is contained in:
1 parent
15b120f729
commit
07033af7dd
44 files changed
+309
-265
No files matched your search
@@ -174,12 +174,12 @@ public class EntityPlayerActionPack
|
||||
List<Entity> entities;
|
||||
if (onlyRideables)
|
||||
{
|
||||
entities = player.level.getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D),
|
||||
entities = player.level().getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D),
|
||||
e -> e instanceof Minecart || e instanceof Boat || e instanceof AbstractHorse);
|
||||
}
|
||||
else
|
||||
{
|
||||
entities = player.level.getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D));
|
||||
entities = player.level().getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D));
|
||||
}
|
||||
if (entities.size()==0)
|
||||
return this;
|
||||
@@ -310,11 +310,11 @@ public class EntityPlayerActionPack
|
||||
case BLOCK:
|
||||
{
|
||||
player.resetLastActionTime();
|
||||
ServerLevel world = player.getLevel();
|
||||
ServerLevel world = player.serverLevel();
|
||||
BlockHitResult blockHit = (BlockHitResult) hit;
|
||||
BlockPos pos = blockHit.getBlockPos();
|
||||
Direction side = blockHit.getDirection();
|
||||
if (pos.getY() < player.getLevel().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
|
||||
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())
|
||||
@@ -349,7 +349,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
}
|
||||
ItemStack handItem = player.getItemInHand(hand);
|
||||
if (player.gameMode.useItem(player, player.getLevel(), handItem, hand).consumesAction())
|
||||
if (player.gameMode.useItem(player, player.level(), handItem, hand).consumesAction())
|
||||
{
|
||||
ap.itemUseCooldown = 3;
|
||||
return true;
|
||||
@@ -392,17 +392,17 @@ public class EntityPlayerActionPack
|
||||
BlockHitResult blockHit = (BlockHitResult) hit;
|
||||
BlockPos pos = blockHit.getBlockPos();
|
||||
Direction side = blockHit.getDirection();
|
||||
if (player.blockActionRestricted(player.level, pos, player.gameMode.getGameModeForPlayer())) return false;
|
||||
if (ap.currentBlock != null && player.level.getBlockState(ap.currentBlock).isAir())
|
||||
if (player.blockActionRestricted(player.level(), pos, player.gameMode.getGameModeForPlayer())) return false;
|
||||
if (ap.currentBlock != null && player.level().getBlockState(ap.currentBlock).isAir())
|
||||
{
|
||||
ap.currentBlock = null;
|
||||
return false;
|
||||
}
|
||||
BlockState state = player.level.getBlockState(pos);
|
||||
BlockState state = player.level().getBlockState(pos);
|
||||
boolean blockBroken = false;
|
||||
if (player.gameMode.getGameModeForPlayer().isCreative())
|
||||
{
|
||||
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
|
||||
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
|
||||
ap.blockHitDelay = 5;
|
||||
blockBroken = true;
|
||||
}
|
||||
@@ -410,15 +410,15 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
if (ap.currentBlock != null)
|
||||
{
|
||||
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
|
||||
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
|
||||
}
|
||||
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
|
||||
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
|
||||
boolean notAir = !state.isAir();
|
||||
if (notAir && ap.curBlockDamageMP == 0)
|
||||
{
|
||||
state.attack(player.level, pos, player);
|
||||
state.attack(player.level(), pos, player);
|
||||
}
|
||||
if (notAir && state.getDestroyProgress(player, player.level, pos) >= 1)
|
||||
if (notAir && state.getDestroyProgress(player, player.level(), pos) >= 1)
|
||||
{
|
||||
ap.currentBlock = null;
|
||||
//instamine??
|
||||
@@ -432,15 +432,15 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
else
|
||||
{
|
||||
ap.curBlockDamageMP += state.getDestroyProgress(player, player.level, pos);
|
||||
ap.curBlockDamageMP += state.getDestroyProgress(player, player.level(), pos);
|
||||
if (ap.curBlockDamageMP >= 1)
|
||||
{
|
||||
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
|
||||
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
|
||||
ap.currentBlock = null;
|
||||
ap.blockHitDelay = 5;
|
||||
blockBroken = true;
|
||||
}
|
||||
player.level.destroyBlockProgress(-1, pos, (int) (ap.curBlockDamageMP * 10));
|
||||
player.level().destroyBlockProgress(-1, pos, (int) (ap.curBlockDamageMP * 10));
|
||||
|
||||
}
|
||||
player.resetLastActionTime();
|
||||
@@ -456,8 +456,8 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
||||
if (ap.currentBlock == null) return;
|
||||
player.level.destroyBlockProgress(-1, ap.currentBlock, -1);
|
||||
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getLevel().getMaxBuildHeight(), -1);
|
||||
player.level().destroyBlockProgress(-1, ap.currentBlock, -1);
|
||||
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.level().getMaxBuildHeight(), -1);
|
||||
ap.currentBlock = null;
|
||||
}
|
||||
},
|
||||
@@ -468,7 +468,7 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
if (action.limit == 1)
|
||||
{
|
||||
if (player.isOnGround()) player.jumpFromGround(); // onGround
|
||||
if (player.onGround()) player.jumpFromGround(); // onGround
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ import net.minecraft.world.level.levelgen.feature.CoralFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralMushroomFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralTreeFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
/**
|
||||
* Deduplicates logic for the different behaviors of the {@code renewableCoral} rule
|
||||
@@ -56,7 +56,7 @@ public interface FertilizableCoral extends BonemealableBlock {
|
||||
default -> new CoralMushroomFeature(NoneFeatureConfiguration.CODEC);
|
||||
};
|
||||
|
||||
MaterialColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
MapColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
BlockState properBlock = blockUnder;
|
||||
HolderSet.Named<Block> coralBlocks = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow();
|
||||
for (Holder<Block> block: coralBlocks)
|
||||
|
||||
@@ -30,7 +30,8 @@ import net.minecraft.world.level.block.AbstractBannerBlock;
|
||||
import net.minecraft.world.level.block.BeaconBeamBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -100,7 +101,7 @@ public class HopperCounter
|
||||
{
|
||||
startTick = -1;
|
||||
this.color = color;
|
||||
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMaterialColor(),"w ") + color.getName();
|
||||
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMapColor(),"w ") + color.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +230,7 @@ public class HopperCounter
|
||||
*/
|
||||
public static int appropriateColor(int color)
|
||||
{
|
||||
if (color == 0) return MaterialColor.SNOW.col;
|
||||
if (color == 0) return MapColor.SNOW.col;
|
||||
int r = (color >> 16 & 255);
|
||||
int g = (color >> 8 & 255);
|
||||
int b = (color & 255);
|
||||
@@ -241,7 +242,7 @@ public class HopperCounter
|
||||
|
||||
/**
|
||||
* Maps items that don't get a good block to reference for colour, or those that colour is wrong to a number of blocks, so we can get their colours easily with the
|
||||
* {@link Block#defaultMaterialColor()} method as these items have those same colours.
|
||||
* {@link Block#defaultMapColor()} method as these items have those same colours.
|
||||
*/
|
||||
private static final Map<Item, Block> DEFAULTS = Map.ofEntries(
|
||||
entry(Items.DANDELION, Blocks.YELLOW_WOOL),
|
||||
@@ -334,8 +335,8 @@ public class HopperCounter
|
||||
*/
|
||||
public static TextColor fromItem(Item item, RegistryAccess registryAccess)
|
||||
{
|
||||
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMaterialColor().col));
|
||||
if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMaterialColor().col));
|
||||
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMapColor().col));
|
||||
if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMapColor().col));
|
||||
Block block = null;
|
||||
final Registry<Item> itemRegistry = registryAccess.registryOrThrow(Registries.ITEM);
|
||||
final Registry<Block> blockRegistry = registryAccess.registryOrThrow(Registries.BLOCK);
|
||||
@@ -350,9 +351,9 @@ public class HopperCounter
|
||||
}
|
||||
if (block != null)
|
||||
{
|
||||
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMaterialColor().col));
|
||||
if (block instanceof BeaconBeamBlock) return TextColor.fromRgb(appropriateColor( ((BeaconBeamBlock) block).getColor().getMaterialColor().col));
|
||||
return TextColor.fromRgb(appropriateColor( block.defaultMaterialColor().col));
|
||||
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMapColor().col));
|
||||
if (block instanceof BeaconBeamBlock) return TextColor.fromRgb(appropriateColor( ((BeaconBeamBlock) block).getColor().getMapColor().col));
|
||||
return TextColor.fromRgb(appropriateColor( block.defaultMapColor().col));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ public class ParticleDisplay
|
||||
{
|
||||
public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, String main, String accent, int count, double spread)
|
||||
{
|
||||
HolderLookup<ParticleType<?>> lookup = player.getLevel().holderLookup(Registries.PARTICLE_TYPE);
|
||||
HolderLookup<ParticleType<?>> lookup = player.level().holderLookup(Registries.PARTICLE_TYPE);
|
||||
ParticleOptions accentParticle = ParticleParser.getEffect(accent, lookup);
|
||||
ParticleOptions mainParticle = ParticleParser.getEffect(main, lookup);
|
||||
|
||||
if (accentParticle != null) player.getLevel().sendParticles(
|
||||
if (accentParticle != null) player.serverLevel().sendParticles(
|
||||
player,
|
||||
accentParticle,
|
||||
true,
|
||||
@@ -29,9 +29,9 @@ public class ParticleDisplay
|
||||
Vec3 incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq));
|
||||
for (Vec3 delta = new Vec3(0.0,0.0,0.0);
|
||||
delta.lengthSqr() < lineLengthSq;
|
||||
delta = delta.add(incvec.scale(player.level.random.nextFloat())))
|
||||
delta = delta.add(incvec.scale(player.level().random.nextFloat())))
|
||||
{
|
||||
player.getLevel().sendParticles(
|
||||
player.serverLevel().sendParticles(
|
||||
player,
|
||||
mainParticle,
|
||||
true,
|
||||
|
||||
Reference in new issue
Block a user