More WIP porting messing around with Codex
This commit is contained in:
parent
5072ae1dd7
commit
ff6776a660
|
|
@ -65,7 +65,7 @@ public class BarrelBlock extends ETankBlock {
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
if (!state.is(newState.getBlock())) {
|
||||
if (level.getBlockEntity(pos) instanceof BarrelBlockEntity barrel) {
|
||||
var item = barrel.getItem();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public abstract class ETankBlock extends EBlock {
|
|||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
||||
if (!level.isClientSide && level.getBlockEntity(pos) instanceof ETankBlockEntity blockEntity) {
|
||||
if (!level.isClientSide() && level.getBlockEntity(pos) instanceof ETankBlockEntity blockEntity) {
|
||||
var tank = blockEntity.getTank();
|
||||
var fluid = tank.getFluid();
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class EndCakeBlock extends CakeBlock {
|
|||
if (bites == 0) {
|
||||
return InteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
if (!player.getAbilities().instabuild) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ public class EndCakeBlock extends CakeBlock {
|
|||
if (!player.isShiftKeyDown()) {
|
||||
int bites = state.getValue(BITES);
|
||||
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
if (tryTeleport((ServerLevel) level, player)) {
|
||||
player.awardStat(Stats.EAT_CAKE_SLICE);
|
||||
player.getFoodData().eat(2, 0.1f);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class InfestedLeavesBlock extends LeavesBlock implements EntityBlock {
|
|||
@Override
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState pState, @Nullable LivingEntity player, ItemStack pStack) {
|
||||
if (player != null) {
|
||||
if (!level.isClientSide && level.getBlockEntity(pos) instanceof InfestedLeavesBlockEntity leaves) {
|
||||
if (!level.isClientSide() && level.getBlockEntity(pos) instanceof InfestedLeavesBlockEntity leaves) {
|
||||
leaves.setProgress(InfestedLeavesBlockEntity.MAX_PROGRESS);
|
||||
}
|
||||
}
|
||||
|
|
@ -118,4 +118,4 @@ public class InfestedLeavesBlock extends LeavesBlock implements EntityBlock {
|
|||
if (FMLEnvironment.dist == Dist.DEDICATED_SERVER) return RenderShape.MODEL;
|
||||
return (EConfig.CLIENT_SPEC.isLoaded() && EConfig.CLIENT.useFastInfestedLeaves.get()) || RenderUtil.IRIS_ACCESS.areShadersEnabled() ? RenderShape.MODEL : RenderShape.INVISIBLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public abstract class MachineBlock extends EBlock {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||
return !level.isClientSide && type == this.blockEntityType.get() ? (BlockEntityTicker<T>) new AbstractMachineBlockEntity.ServerTicker<>() : null;
|
||||
return !level.isClientSide() && type == this.blockEntityType.get() ? (BlockEntityTicker<T>) new AbstractMachineBlockEntity.ServerTicker<>() : null;
|
||||
}
|
||||
|
||||
// Slot in the machine's inventory where the mesh/hammer is
|
||||
|
|
@ -96,7 +96,7 @@ public abstract class MachineBlock extends EBlock {
|
|||
// Drops the item for creative mode players
|
||||
@Override
|
||||
public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState pState, Player player) {
|
||||
if (!level.isClientSide && player.isCreative() && level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) {
|
||||
if (!level.isClientSide() && player.isCreative() && level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) {
|
||||
if (level.getBlockEntity(pos) instanceof AbstractMachineBlockEntity<?> machine) {
|
||||
if (!machine.inventory.getStackInSlot(getHighlightItemSlot()).isEmpty()) {
|
||||
var stack = new ItemStack(this);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class SieveBlock extends EBlock {
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean pIsMoving) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
if (!state.is(newState.getBlock())) {
|
||||
if (level.getBlockEntity(pos) instanceof AbstractSieveBlockEntity sieve) {
|
||||
var mesh = sieve.getLogic().getMesh();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class WitchWaterBlock extends LiquidBlock {
|
|||
|
||||
@Override
|
||||
public void entityInside(BlockState pState, Level level, BlockPos pPos, Entity entity) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
witchWaterEntityEffects(level, entity);
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ public class WitchWaterBlock extends LiquidBlock {
|
|||
} else if (entityType == EntityType.PUFFERFISH) {
|
||||
attemptToConvertEntity(level, entity, EntityType.GUARDIAN);
|
||||
} else if (entityType == EntityType.HORSE) {
|
||||
if (level.random.nextBoolean()) {
|
||||
if (level.getRandom().nextBoolean()) {
|
||||
attemptToConvertEntity(level, entity, EntityType.ZOMBIE_HORSE);
|
||||
} else {
|
||||
attemptToConvertEntity(level, entity, EntityType.SKELETON_HORSE);
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity {
|
|||
public InteractionResult useItemOn(Level level, Player player, ItemStack stack, InteractionHand hand) {
|
||||
var playerItem = player.getItemInHand(hand);
|
||||
|
||||
if (playerItem.getCapability(Capabilities.FluidHandler.ITEM) != null) {
|
||||
if (playerItem.getCapability(Capabilities.Fluid.ITEM) != null) {
|
||||
return FluidUtil.interactWithFluidHandler(player, hand, this.tank) ? InteractionResult.SUCCESS : InteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity {
|
|||
var fluid = new FluidStack(Fluids.WATER, 250);
|
||||
|
||||
if (this.tank.drain(fluid, IFluidHandler.FluidAction.SIMULATE).getAmount() == 250) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
BarrelBlockEntity.extractWaterBottle(this.tank, level, player, playerItem, fluid);
|
||||
markUpdated();
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity {
|
|||
this.item.setStackInSlot(0, ItemStack.EMPTY);
|
||||
return false;
|
||||
}
|
||||
if (this.level != null && this.level.isClientSide) {
|
||||
if (this.level != null && this.level.isClientSide()) {
|
||||
return true;
|
||||
}
|
||||
var result = recipe.getResult();
|
||||
|
|
@ -292,7 +292,7 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity {
|
|||
var item = sapling.getValue().asItem();
|
||||
|
||||
if (!overrides.containsKey(item)) {
|
||||
var key = sapling.getKey().location();
|
||||
var key = sapling.getKey().identifier();
|
||||
|
||||
if (key.getPath().endsWith("sapling")) {
|
||||
try {
|
||||
|
|
@ -342,7 +342,7 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity {
|
|||
@Override
|
||||
public void tick(Level level, BlockPos pos, BlockState state, AbstractCrucibleBlockEntity crucible) {
|
||||
// Update twice per second
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
var tank = crucible.tank;
|
||||
|
||||
if ((level.getGameTime() % 10L) == 0L) {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
package thedarkcolour.exdeorum.blockentity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.stats.Stats;
|
||||
|
|
@ -32,6 +30,8 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import net.minecraft.world.level.storage.ValueOutput;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
|
@ -74,17 +74,15 @@ public abstract class AbstractSieveBlockEntity extends EBlockEntity implements S
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(nbt, registries);
|
||||
|
||||
this.logic.saveNbt(nbt, registries);
|
||||
protected void saveAdditional(ValueOutput output) {
|
||||
super.saveAdditional(output);
|
||||
this.logic.saveNbt(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(nbt, registries);
|
||||
|
||||
this.logic.loadNbt(nbt, registries);
|
||||
public void loadAdditional(ValueInput input) {
|
||||
super.loadAdditional(input);
|
||||
this.logic.loadNbt(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -110,7 +108,7 @@ public abstract class AbstractSieveBlockEntity extends EBlockEntity implements S
|
|||
@Override
|
||||
public InteractionResult useItemOn(Level level, Player player, ItemStack stack, InteractionHand hand) {
|
||||
ItemStack playerItem = player.getItemInHand(hand);
|
||||
boolean isClientSide = level.isClientSide;
|
||||
boolean isClientSide = level.isClientSide();
|
||||
|
||||
// Try insert mesh
|
||||
if (this.logic.getMesh().isEmpty()) {
|
||||
|
|
@ -242,10 +240,10 @@ public abstract class AbstractSieveBlockEntity extends EBlockEntity implements S
|
|||
|
||||
// Do not call on client side
|
||||
public static void popOutMesh(Level level, BlockPos sievePos, SieveLogic logic) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
// Pop out item
|
||||
var itemEntity = new ItemEntity(level, sievePos.getX() + 0.5, sievePos.getY() + 1.5, sievePos.getZ() + 0.5, logic.getMesh());
|
||||
var rand = level.random;
|
||||
var rand = level.getRandom();
|
||||
itemEntity.setDeltaMovement(rand.nextGaussian() * 0.05, 0.2, rand.nextGaussian() * 0.05);
|
||||
level.addFreshEntity(itemEntity);
|
||||
|
||||
|
|
|
|||
|
|
@ -263,14 +263,14 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
}
|
||||
|
||||
// Otherwise, mix the item's fluid into the barrel's fluid
|
||||
var itemFluidCap = playerItem.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var itemFluidCap = playerItem.getCapability(Capabilities.Fluid.ITEM);
|
||||
if (itemFluidCap != null) {
|
||||
var itemFluid = itemFluidCap.drain(1000, IFluidHandler.FluidAction.SIMULATE);
|
||||
BarrelFluidMixingRecipe recipe = RecipeUtil.getFluidMixingRecipe(this.tank.getFluid(), itemFluid.getFluid());
|
||||
|
||||
// If draining item fluid was possible and tank has enough fluid to mix...
|
||||
if (recipe != null && this.tank.getFluidAmount() >= recipe.baseFluid().amount() && itemFluid.getAmount() == 1000) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
this.tank.drain(recipe.baseFluid().amount(), IFluidHandler.FluidAction.EXECUTE);
|
||||
setItem(recipe.result().copy());
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
|
||||
// If the barrel has no solids and no fluid mixing/transfer happened
|
||||
var playerItem = player.getItemInHand(hand);
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
// mix item ingredient into fluid OR turn into compost (delegated to item handler)
|
||||
var handItem = this.item.insertItem(0, player.getAbilities().instabuild ? playerItem.copy() : playerItem, false);
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
|
||||
// Pops the item out of the barrel (ex. dirt that has finished composting)
|
||||
private InteractionResult giveResultItem(Level level) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
popOutItem(level, this.worldPosition, this.item.extract(false));
|
||||
|
||||
// Empty contents
|
||||
|
|
@ -329,8 +329,8 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
}
|
||||
|
||||
private static void popOutItem(Level level, BlockPos pos, ItemStack stack) {
|
||||
if (!level.isClientSide && !stack.isEmpty()) {
|
||||
var rand = level.random;
|
||||
if (!level.isClientSide() && !stack.isEmpty()) {
|
||||
var rand = level.getRandom();
|
||||
var itemEntity = new ItemEntity(level, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, stack);
|
||||
itemEntity.setDeltaMovement(rand.nextGaussian() * 0.05, 0.2, rand.nextGaussian() * 0.05);
|
||||
level.addFreshEntity(itemEntity);
|
||||
|
|
@ -429,7 +429,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
* <li> When the fluid in the barrel changes (see {@link FluidHandler#onContentsChanged()}) </li>
|
||||
*/
|
||||
public void tryInWorldFluidMixing() {
|
||||
if (!this.level.isClientSide) {
|
||||
if (!this.level.isClientSide()) {
|
||||
if (!this.tank.isEmpty() && this.item.getStackInSlot(0).isEmpty()) {
|
||||
var abovePos = this.worldPosition.above();
|
||||
var aboveBlockState = this.level.getBlockState(abovePos);
|
||||
|
|
@ -459,7 +459,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
}
|
||||
|
||||
public void updateFluidTransform() {
|
||||
if (!this.level.isClientSide) {
|
||||
if (!this.level.isClientSide()) {
|
||||
if (this.tank.getFluidAmount() != MAX_CAPACITY) {
|
||||
this.currentTransformRecipe = null;
|
||||
} else {
|
||||
|
|
@ -485,7 +485,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
public static class Ticker implements BlockEntityTicker<BarrelBlockEntity> {
|
||||
@Override
|
||||
public void tick(Level level, BlockPos pos, BlockState state, BarrelBlockEntity barrel) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
var tank = barrel.tank;
|
||||
// Turn compost to dirt
|
||||
if (barrel.isComposting()) {
|
||||
|
|
@ -509,7 +509,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
catalysts++;
|
||||
|
||||
if (!recipe.byproducts().isEmpty()) {
|
||||
var rand = level.random;
|
||||
var rand = level.getRandom();
|
||||
|
||||
if (rand.nextInt(1500) == 0) {
|
||||
var above = cursor.above();
|
||||
|
|
@ -548,7 +548,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
}
|
||||
} else if (barrel.hasFullWater()) {
|
||||
if (tank.getFluid().getFluid().getFluidType() == NeoForgeMod.WATER_TYPE.value()) {
|
||||
var rand = level.random;
|
||||
var rand = level.getRandom();
|
||||
// Leak water to create moss (only wooden barrels do this)
|
||||
if (state.ignitedByLava() && rand.nextInt(500) == 0) {
|
||||
var randomPos = pos.offset(rand.nextIntBetweenInclusive(-MOSS_SPREAD_RANGE, MOSS_SPREAD_RANGE), -1, rand.nextIntBetweenInclusive(-MOSS_SPREAD_RANGE, MOSS_SPREAD_RANGE));
|
||||
|
|
@ -644,7 +644,7 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
if (!BarrelBlockEntity.this.level.isClientSide) {
|
||||
if (!BarrelBlockEntity.this.level.isClientSide()) {
|
||||
markUpdated();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,14 +19,13 @@
|
|||
package thedarkcolour.exdeorum.blockentity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import net.minecraft.world.level.storage.ValueOutput;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
|
|
@ -80,9 +79,9 @@ public class InfestedLeavesBlockEntity extends EBlockEntity {
|
|||
// Attempt to convert a leaf block within 1 block radius around this block
|
||||
private void trySpread(Level level) {
|
||||
// Get random offset
|
||||
int x = level.random.nextInt(3) - 1;
|
||||
int y = level.random.nextInt(3) - 1;
|
||||
int z = level.random.nextInt(3) - 1;
|
||||
int x = level.getRandom().nextInt(3) - 1;
|
||||
int y = level.getRandom().nextInt(3) - 1;
|
||||
int z = level.getRandom().nextInt(3) - 1;
|
||||
|
||||
// Get the block in the world
|
||||
BlockPos targetPos = getBlockPos().offset(x, y, z);
|
||||
|
|
@ -103,24 +102,25 @@ public class InfestedLeavesBlockEntity extends EBlockEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void loadAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(nbt, registries);
|
||||
public void loadAdditional(ValueInput input) {
|
||||
super.loadAdditional(input);
|
||||
|
||||
// From PistonMovingBlockEntity
|
||||
var holderLookup = this.level != null ? this.level.holderLookup(Registries.BLOCK) : BuiltInRegistries.BLOCK.asLookup();
|
||||
this.mimic = NbtUtils.readBlockState(holderLookup, nbt.getCompound("mimic"));
|
||||
this.progress = nbt.getShort("progress");
|
||||
var holderLookup = input.lookup().lookupOrThrow(Registries.BLOCK);
|
||||
this.mimic = input.child("mimic")
|
||||
.map(child -> NbtUtils.readBlockState(holderLookup, child.asTag()))
|
||||
.orElse(Blocks.OAK_LEAVES.defaultBlockState());
|
||||
this.progress = (short) input.getShortOr("progress", (short) 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(nbt, registries);
|
||||
public void saveAdditional(ValueOutput output) {
|
||||
super.saveAdditional(output);
|
||||
|
||||
if (this.mimic == null || this.mimic.getBlock() == EBlocks.INFESTED_LEAVES.get()) {
|
||||
this.mimic = Blocks.OAK_LEAVES.defaultBlockState();
|
||||
}
|
||||
nbt.put("mimic", NbtUtils.writeBlockState(this.mimic));
|
||||
nbt.putShort("progress", this.progress);
|
||||
output.child("mimic").store(NbtUtils.writeBlockState(this.mimic));
|
||||
output.putShort("progress", this.progress);
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
|
|
@ -157,13 +157,13 @@ public class InfestedLeavesBlockEntity extends EBlockEntity {
|
|||
}
|
||||
|
||||
// If the leave is infested enough, advance the spread timer
|
||||
if (!level.isClientSide && leaves.progress >= SPREAD_THRESHOLD) {
|
||||
if (!level.isClientSide() && leaves.progress >= SPREAD_THRESHOLD) {
|
||||
++leaves.spreadTimer;
|
||||
|
||||
// Attempt to spread and reset the timer
|
||||
if (leaves.spreadTimer >= SPREAD_INTERVAL) {
|
||||
leaves.trySpread(level);
|
||||
leaves.spreadTimer = level.random.nextInt(10);
|
||||
leaves.spreadTimer = level.getRandom().nextInt(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,9 @@
|
|||
|
||||
package thedarkcolour.exdeorum.blockentity.helper;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
import net.neoforged.neoforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
|
||||
// Changed behavior from FluidTank:
|
||||
// - fluid stacks read from NBT are clamped.
|
||||
|
|
@ -71,12 +70,10 @@ public class FluidHelper extends FluidTank {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidTank readFromNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||
super.readFromNBT(provider, nbt);
|
||||
public void deserialize(ValueInput input) {
|
||||
super.deserialize(input);
|
||||
if (!this.fluid.isEmpty()) {
|
||||
this.fluid.setAmount(Math.min(this.capacity, this.fluid.getAmount()));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class ClientHandler {
|
|||
originalDefaultWorldPreset = originalPreset;
|
||||
}
|
||||
if (originalDefaultWorldPreset.unwrapKey().equals(originalPreset.unwrapKey())) {
|
||||
var voidWorldPreset = uiState.getSettings().worldgenLoadContext().registryOrThrow(Registries.WORLD_PRESET).getHolder(ASMHooks.overrideDefaultWorldPreset()).orElse(null);
|
||||
var voidWorldPreset = uiState.getSettings().worldgenLoadContext().lookupOrThrow(Registries.WORLD_PRESET).get(ASMHooks.overrideDefaultWorldPreset()).orElse(null);
|
||||
uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(voidWorldPreset));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class CompostColors {
|
|||
var readMods = readModdedColorFiles();
|
||||
|
||||
for (var entry : BuiltInRegistries.ITEM.entrySet()) {
|
||||
var key = entry.getKey().location();
|
||||
var key = entry.getKey().identifier();
|
||||
var modid = key.getNamespace();
|
||||
|
||||
if (!readMods.contains(modid)) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.client.data.models.model.ModelInstance;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import thedarkcolour.exdeorum.material.DefaultMaterials;
|
||||
|
|
@ -29,6 +30,8 @@ import thedarkcolour.exdeorum.registry.EBlocks;
|
|||
import thedarkcolour.exdeorum.registry.ECompressedBlocks;
|
||||
import thedarkcolour.modkit.data.MKBlockModelProvider;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
|
||||
class BlockModels {
|
||||
|
|
@ -41,7 +44,7 @@ class BlockModels {
|
|||
|
||||
ModelBuilder(MKBlockModelProvider models, Identifier modelId, JsonObject json) {
|
||||
this.json = json;
|
||||
models.acceptModel(modelId, () -> json);
|
||||
acceptModel(models, modelId, () -> json);
|
||||
}
|
||||
|
||||
public ModelBuilder renderType(String type) {
|
||||
|
|
@ -278,7 +281,7 @@ class BlockModels {
|
|||
itemRenderOrder.add("overlay");
|
||||
json.add("item_render_order", itemRenderOrder);
|
||||
|
||||
models.acceptModel(modelId, () -> json);
|
||||
acceptModel(models, modelId, () -> json);
|
||||
models.simpleBlock(block, modelId);
|
||||
}
|
||||
|
||||
|
|
@ -308,6 +311,16 @@ class BlockModels {
|
|||
return Identifier.fromNamespaceAndPath(key.getNamespace(), "block/" + prefix + key.getPath() + suffix);
|
||||
}
|
||||
|
||||
private static void acceptModel(MKBlockModelProvider models, Identifier modelId, ModelInstance model) {
|
||||
try {
|
||||
Method acceptModel = MKBlockModelProvider.class.getDeclaredMethod("acceptModel", Identifier.class, ModelInstance.class);
|
||||
acceptModel.setAccessible(true);
|
||||
acceptModel.invoke(models, modelId, model);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException exception) {
|
||||
throw new IllegalStateException("Unable to register generated model " + modelId, exception);
|
||||
}
|
||||
}
|
||||
|
||||
public static void barrel(MKBlockModelProvider models, Block block, Block appearance) {
|
||||
barrel(models, block, appearance, "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ import static thedarkcolour.modkit.data.MKRecipeProvider.id;
|
|||
|
||||
public class Recipes {
|
||||
private static final Ingredient SPORES_AND_SEEDS = ingredient(EItems.GRASS_SEEDS, EItems.MYCELIUM_SPORES, EItems.WARPED_NYLIUM_SPORES, EItems.CRIMSON_NYLIUM_SPORES);
|
||||
private static final TagKey<Item> TALL_FLOWERS = ItemTags.create(Identifier.withDefaultNamespace("tall_flowers"));
|
||||
|
||||
public static void addRecipes(RecipeOutput writer, MKRecipeProvider recipes) {
|
||||
craftingRecipes(writer, recipes);
|
||||
|
|
@ -512,7 +513,7 @@ public class Recipes {
|
|||
waterCrucible(writer, "saplings", recipes.ingredient(ItemTags.SAPLINGS), 100);
|
||||
waterCrucible(writer, "leaves", recipes.ingredient(ItemTags.LEAVES), 250);
|
||||
waterCrucible(writer, "small_flowers", recipes.ingredient(ItemTags.SMALL_FLOWERS), 100);
|
||||
waterCrucible(writer, "tall_flowers", recipes.ingredient(ItemTags.TALL_FLOWERS), 200);
|
||||
waterCrucible(writer, "tall_flowers", recipes.ingredient(TALL_FLOWERS), 200);
|
||||
waterCrucible(writer, "mushrooms", recipes.ingredient(Tags.Items.MUSHROOMS), 100);
|
||||
waterCrucible(writer, "lily_pad", ingredient(Items.LILY_PAD), 150);
|
||||
waterCrucible(writer, "sugar_cane", ingredient(Items.SUGAR_CANE), 100);
|
||||
|
|
@ -646,7 +647,7 @@ public class Recipes {
|
|||
barrelCompost(writer, "saplings", recipes.ingredient(ItemTags.SAPLINGS), 125);
|
||||
barrelCompost(writer, "leaves", recipes.ingredient(ItemTags.LEAVES), 125);
|
||||
barrelCompost(writer, "small_flowers", recipes.ingredient(ItemTags.SMALL_FLOWERS), 100);
|
||||
barrelCompost(writer, "tall_flowers", recipes.ingredient(ItemTags.TALL_FLOWERS), 150);
|
||||
barrelCompost(writer, "tall_flowers", recipes.ingredient(TALL_FLOWERS), 150);
|
||||
barrelCompost(writer, "mushrooms", recipes.ingredient(Tags.Items.MUSHROOMS), 100);
|
||||
barrelCompost(writer, "lily_pad", ingredient(Items.LILY_PAD), 100);
|
||||
barrelCompost(writer, "sugar_cane", ingredient(Items.SUGAR_CANE), 80);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.XoroshiroRandomSource;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.storage.LevelData;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.InterModComms;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
|
@ -108,7 +109,7 @@ public final class EventHandler {
|
|||
CompostColors.loadColors();
|
||||
var player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
player.displayClientMessage(Component.literal("Reloaded " + CompostColors.COLORS.size() + " compost colors!"), false);
|
||||
player.sendSystemMessage(Component.literal("Reloaded " + CompostColors.COLORS.size() + " compost colors!"));
|
||||
}
|
||||
} else if (event.getMessage().equals(".breakpoint")) {
|
||||
event.setCanceled(true);
|
||||
|
|
@ -123,14 +124,14 @@ public final class EventHandler {
|
|||
pos.move(0, 1, 0);
|
||||
|
||||
// grow tree, has 5% chance to spawn bees based on world seed
|
||||
var configuredFeatureRegistry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
|
||||
var configuredFeatureRegistry = level.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE);
|
||||
var defaultTreeFeature = TreeFeatures.OAK_BEES_005;
|
||||
var defaultTreeFeatureLoc = Identifier.tryParse(EConfig.SERVER.defaultSpawnTreeFeature.get());
|
||||
|
||||
Holder<ConfiguredFeature<?, ?>> holder = configuredFeatureRegistry.getHolder(defaultTreeFeature).orElse(null);
|
||||
Holder<ConfiguredFeature<?, ?>> holder = configuredFeatureRegistry.get(defaultTreeFeature).orElse(null);
|
||||
|
||||
if (defaultTreeFeatureLoc != null) {
|
||||
var value = configuredFeatureRegistry.getHolder(ResourceKey.create(Registries.CONFIGURED_FEATURE, defaultTreeFeatureLoc)).orElse(null);
|
||||
var value = configuredFeatureRegistry.get(ResourceKey.create(Registries.CONFIGURED_FEATURE, defaultTreeFeatureLoc)).orElse(null);
|
||||
if (value != null) {
|
||||
holder = value;
|
||||
}
|
||||
|
|
@ -158,8 +159,8 @@ public final class EventHandler {
|
|||
}
|
||||
|
||||
event.setCanceled(true);
|
||||
event.getSettings().setSpawn(level.getHeightmapPos(Heightmap.Types.WORLD_SURFACE_WG, pos), 90.0F);
|
||||
level.getGameRules().getRule(GameRules.RULE_SPAWN_RADIUS).set(0, level.getServer());
|
||||
event.getSettings().setSpawn(LevelData.RespawnData.of(level.dimension(), level.getHeightmapPos(Heightmap.Types.WORLD_SURFACE_WG, pos), 90.0F, 0.0F));
|
||||
level.getGameRules().getRule(GameRules.RESPAWN_RADIUS).set(0, level.getServer());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,12 +189,12 @@ public final class EventHandler {
|
|||
|
||||
private static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (event.getEntity() instanceof ServerPlayer player) {
|
||||
var generator = player.serverLevel().getChunkSource().getGenerator();
|
||||
var generator = ((ServerLevel) player.level()).getChunkSource().getGenerator();
|
||||
|
||||
// tries to account for other SkyBlock generator mods like SkyBlockBuilder
|
||||
if (generator instanceof VoidChunkGenerator || generator.getClass().getName().toLowerCase(Locale.ROOT).contains("skyblock")) {
|
||||
NetworkHandler.sendVoidWorld(player);
|
||||
var advancement = player.server.getAdvancements().get(Identifier.fromNamespaceAndPath(ExDeorum.ID, "core/root"));
|
||||
var advancement = player.getServer().getAdvancements().get(Identifier.fromNamespaceAndPath(ExDeorum.ID, "core/root"));
|
||||
|
||||
if (advancement != null) {
|
||||
if (!player.getAdvancements().getOrStartProgress(advancement).isDone()) {
|
||||
|
|
@ -237,28 +238,28 @@ public final class EventHandler {
|
|||
}
|
||||
|
||||
private static void registerCapabilities(RegisterCapabilitiesEvent event) {
|
||||
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK, EBlockEntities.BARREL.get(), (barrel, direction) -> barrel.getItemHandler());
|
||||
event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, EBlockEntities.BARREL.get(), (barrel, direction) -> barrel.getTank());
|
||||
event.registerBlockEntity(Capabilities.Item.BLOCK, EBlockEntities.BARREL.get(), (barrel, direction) -> barrel.getItemHandler());
|
||||
event.registerBlockEntity(Capabilities.Fluid.BLOCK, EBlockEntities.BARREL.get(), (barrel, direction) -> barrel.getTank());
|
||||
|
||||
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK, EBlockEntities.MECHANICAL_SIEVE.get(), (sieve, direction) -> sieve.getItemHandler());
|
||||
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, EBlockEntities.MECHANICAL_SIEVE.get(), (sieve, direction) -> sieve.getEnergyStorage());
|
||||
event.registerBlockEntity(Capabilities.Item.BLOCK, EBlockEntities.MECHANICAL_SIEVE.get(), (sieve, direction) -> sieve.getItemHandler());
|
||||
event.registerBlockEntity(Capabilities.Energy.BLOCK, EBlockEntities.MECHANICAL_SIEVE.get(), (sieve, direction) -> sieve.getEnergyStorage());
|
||||
|
||||
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK, EBlockEntities.MECHANICAL_HAMMER.get(), (hammer, direction) -> hammer.getItemHandler());
|
||||
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, EBlockEntities.MECHANICAL_HAMMER.get(), (hammer, direction) -> hammer.getEnergyStorage());
|
||||
event.registerBlockEntity(Capabilities.Item.BLOCK, EBlockEntities.MECHANICAL_HAMMER.get(), (hammer, direction) -> hammer.getItemHandler());
|
||||
event.registerBlockEntity(Capabilities.Energy.BLOCK, EBlockEntities.MECHANICAL_HAMMER.get(), (hammer, direction) -> hammer.getEnergyStorage());
|
||||
|
||||
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK, EBlockEntities.LAVA_CRUCIBLE.get(), (hammer, direction) -> hammer.getItem());
|
||||
event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, EBlockEntities.LAVA_CRUCIBLE.get(), (hammer, direction) -> hammer.getTank());
|
||||
event.registerBlockEntity(Capabilities.Item.BLOCK, EBlockEntities.LAVA_CRUCIBLE.get(), (hammer, direction) -> hammer.getItem());
|
||||
event.registerBlockEntity(Capabilities.Fluid.BLOCK, EBlockEntities.LAVA_CRUCIBLE.get(), (hammer, direction) -> hammer.getTank());
|
||||
|
||||
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK, EBlockEntities.WATER_CRUCIBLE.get(), (hammer, direction) -> hammer.getItem());
|
||||
event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, EBlockEntities.WATER_CRUCIBLE.get(), (hammer, direction) -> hammer.getTank());
|
||||
event.registerBlockEntity(Capabilities.Item.BLOCK, EBlockEntities.WATER_CRUCIBLE.get(), (hammer, direction) -> hammer.getItem());
|
||||
event.registerBlockEntity(Capabilities.Fluid.BLOCK, EBlockEntities.WATER_CRUCIBLE.get(), (hammer, direction) -> hammer.getTank());
|
||||
|
||||
event.registerItem(Capabilities.FluidHandler.ITEM, (stack, ctx) -> new PorcelainBucket.ItemHandler(stack),
|
||||
event.registerItem(Capabilities.Fluid.ITEM, (stack, ctx) -> new PorcelainBucket.ItemHandler(stack),
|
||||
EItems.PORCELAIN_BUCKET,
|
||||
EItems.PORCELAIN_WATER_BUCKET,
|
||||
EItems.PORCELAIN_LAVA_BUCKET,
|
||||
EItems.PORCELAIN_MILK_BUCKET,
|
||||
EItems.PORCELAIN_WITCH_WATER_BUCKET);
|
||||
event.registerItem(Capabilities.FluidHandler.ITEM, (stack, ctx) -> new WateringCanItem.FluidHandler(stack),
|
||||
event.registerItem(Capabilities.Fluid.ITEM, (stack, ctx) -> new WateringCanItem.FluidHandler(stack),
|
||||
EItems.WOODEN_WATERING_CAN,
|
||||
EItems.STONE_WATERING_CAN,
|
||||
EItems.IRON_WATERING_CAN,
|
||||
|
|
|
|||
|
|
@ -54,17 +54,14 @@ public class WitchWaterFluid extends FluidType {
|
|||
|
||||
public static IClientFluidTypeExtensions createClientExtensions() {
|
||||
return new IClientFluidTypeExtensions() {
|
||||
@Override
|
||||
public Identifier getStillTexture() {
|
||||
return STILL_TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getFlowingTexture() {
|
||||
return FLOWING_TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getOverlayTexture() {
|
||||
return OVERLAY_TEXTURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ public class CookedSilkwormItem extends Item {
|
|||
}
|
||||
|
||||
// Yummy silk worms :)
|
||||
@Override
|
||||
public SoundEvent getEatingSound() {
|
||||
return ESounds.SILK_WORM_EAT.get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,25 +54,22 @@ public class CrookItem extends Item {
|
|||
|
||||
@Override
|
||||
public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity living) {
|
||||
if (!level.isClientSide && state.getDestroySpeed(level, pos) != 0.0F) {
|
||||
if (!level.isClientSide() && state.getDestroySpeed(level, pos) != 0.0F) {
|
||||
stack.hurtAndBreak(1, living, EquipmentSlot.MAINHAND);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimaryItemFor(ItemStack stack, Holder<Enchantment> enchantment) {
|
||||
var key = enchantment.getKey();
|
||||
return key == Enchantments.FORTUNE || key == Enchantments.UNBREAKING || key == Enchantments.EFFICIENCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidRepairItem(ItemStack tool, ItemStack material) {
|
||||
if (this == EItems.BONE_CROOK.get()) {
|
||||
return material.is(Tags.Items.BONES);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import net.minecraft.tags.BlockTags;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.animal.cow.Cow;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -55,7 +56,7 @@ public class GrassSpreaderItem extends Item {
|
|||
var grass = this.grassState.get();
|
||||
|
||||
if (canSpread(state) && grass != state) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
level.setBlock(pos, grass, 3);
|
||||
level.playSound(null, pos, ESounds.GRASS_SEEDS_PLACE.get(), SoundSource.BLOCKS);
|
||||
|
||||
|
|
@ -77,14 +78,14 @@ public class GrassSpreaderItem extends Item {
|
|||
@Override
|
||||
public InteractionResult interactLivingEntity(ItemStack stack, Player player, LivingEntity target, InteractionHand pUsedHand) {
|
||||
if (stack.getItem() == EItems.MYCELIUM_SPORES.get() && target instanceof Cow cow) {
|
||||
var mushroomCow = EntityType.MOOSHROOM.create(cow.level());
|
||||
var mushroomCow = EntityType.MOOSHROOM.create(cow.level(), EntitySpawnReason.CONVERSION);
|
||||
|
||||
if (mushroomCow != null) {
|
||||
if (!player.getAbilities().instabuild) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
cow.discard();
|
||||
mushroomCow.moveTo(cow.getX(), cow.getY(), cow.getZ());
|
||||
mushroomCow.setPos(cow.getX(), cow.getY(), cow.getZ());
|
||||
mushroomCow.setHealth(cow.getHealth());
|
||||
mushroomCow.yBodyRot = cow.yBodyRot;
|
||||
|
||||
|
|
@ -98,7 +99,7 @@ public class GrassSpreaderItem extends Item {
|
|||
mushroomCow.setInvulnerable(cow.isInvulnerable());
|
||||
cow.level().addFreshEntity(mushroomCow);
|
||||
|
||||
if (!cow.level().isClientSide) {
|
||||
if (!cow.level().isClientSide()) {
|
||||
((ServerLevel)cow.level()).sendParticles(ParticleTypes.EXPLOSION, cow.getX(), cow.getY(0.5D), cow.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
cow.playSound(SoundEvents.MOOSHROOM_CONVERT, 2.0F, 1.0F);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public class HammerItem extends Item {
|
|||
super(material.applyToolProperties(properties, EBlockTags.MINEABLE_WITH_HAMMER, 1.5f, -2.8f, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack stack, @Nullable RecipeType<?> recipeType) {
|
||||
return (this == EItems.WOODEN_HAMMER.get() || this == EItems.COMPRESSED_WOODEN_HAMMER.get()) ? 200 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,18 +29,15 @@ public class MeshItem extends Item {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimaryItemFor(ItemStack stack, Holder<Enchantment> enchantment) {
|
||||
var key = enchantment.getKey();
|
||||
return key == Enchantments.EFFICIENCY || key == Enchantments.FORTUNE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnchantable(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return 10;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class PorcelainBucket extends Item {
|
|||
var result = ItemUtils.createFilledResult(stack.getCount() == 1 ? stack.copy() : stack, player, new ItemStack(EItems.PORCELAIN_MILK_BUCKET.get()));
|
||||
player.setItemInHand(hand, result);
|
||||
}
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ public class PorcelainBucket extends Item {
|
|||
pickup.getPickupSound(state).ifPresent(sound -> player.playSound(sound, 1.0F, 1.0F));
|
||||
level.gameEvent(player, GameEvent.FLUID_PICKUP, pos);
|
||||
var filled = ItemUtils.createFilledResult(stack, player, result);
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer) player, result);
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ public class PorcelainBucket extends Item {
|
|||
} else if (containedFluidStack.isPresent() && this.fluid.get().getFluidType().isVaporizedOnPlacement(level, pos, containedFluidStack.get())) {
|
||||
this.fluid.get().getFluidType().onVaporize(player, level, pos, containedFluidStack.get());
|
||||
return true;
|
||||
} else if (level.dimensionType().ultraWarm() && this.fluid.get().is(FluidTags.WATER)) {
|
||||
} else if (level.dimension() == Level.NETHER && this.fluid.get().is(FluidTags.WATER)) {
|
||||
var i = pos.getX();
|
||||
var j = pos.getY();
|
||||
var k = pos.getZ();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class PorcelainMilkBucket extends Item {
|
|||
|
||||
@Override
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity living) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
living.removeAllEffects();
|
||||
}
|
||||
return new ItemStack(EItems.PORCELAIN_BUCKET.get());
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import net.minecraft.world.InteractionResult;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipDisplay;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.component.TooltipDisplay;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class SculkCoreItem extends Item {
|
|||
}
|
||||
level.playSound(null, pos, ESounds.SCULK_CORE_ACTIVATE.get(), SoundSource.BLOCKS, 1.0f, 1.0f);
|
||||
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
|
||||
return InteractionResult.PASS;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class SilkwormItem extends Item {
|
|||
|
||||
if (!state.isAir()) {
|
||||
if (state.is(BlockTags.LEAVES) && state.getBlock() != EBlocks.INFESTED_LEAVES.get()) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
// Replace with infested block
|
||||
InfestedLeavesBlock.setBlock(level, pos, state);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public class SilkwormItem extends Item {
|
|||
context.getItemInHand().shrink(1);
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(level.isClientSide);
|
||||
return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class WateringCanItem extends Item {
|
|||
|
||||
public static ItemStack getFull(Supplier<? extends Item> wateringCan) {
|
||||
var stack = new ItemStack(wateringCan.get());
|
||||
var fluidHandler = stack.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = stack.getCapability(Capabilities.Fluid.ITEM);
|
||||
if (fluidHandler != null) {
|
||||
fluidHandler.fill(new FluidStack(Fluids.WATER, Integer.MAX_VALUE), IFluidHandler.FluidAction.EXECUTE);
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ public class WateringCanItem extends Item {
|
|||
@Override
|
||||
public boolean isBarVisible(ItemStack stack) {
|
||||
if (this.renewing) {
|
||||
var fluidHandler = stack.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = stack.getCapability(Capabilities.Fluid.ITEM);
|
||||
return fluidHandler == null || fluidHandler.getFluidInTank(0).getAmount() < this.capacity;
|
||||
} else {
|
||||
return true;
|
||||
|
|
@ -118,7 +118,7 @@ public class WateringCanItem extends Item {
|
|||
|
||||
@Override
|
||||
public int getBarWidth(ItemStack stack) {
|
||||
var fluidHandler = stack.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = stack.getCapability(Capabilities.Fluid.ITEM);
|
||||
if (fluidHandler != null) {
|
||||
return Math.round((float) fluidHandler.getFluidInTank(0).getAmount() * 13f / (float) this.capacity);
|
||||
} else {
|
||||
|
|
@ -136,9 +136,8 @@ public class WateringCanItem extends Item {
|
|||
return ItemUseAnimation.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltip, TooltipFlag pIsAdvanced) {
|
||||
var fluidHandler = stack.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = stack.getCapability(Capabilities.Fluid.ITEM);
|
||||
if (fluidHandler != null) {
|
||||
// use the block name which is guaranteed to have a vanilla translation
|
||||
tooltip.add(Component.translatable("block.minecraft.water").append(Component.translatable(TranslationKeys.FRACTION_DISPLAY, fluidHandler.getFluidInTank(0).getAmount(), this.capacity)).withStyle(ChatFormatting.GRAY));
|
||||
|
|
@ -148,7 +147,7 @@ public class WateringCanItem extends Item {
|
|||
@Override
|
||||
public InteractionResult use(Level level, Player player, InteractionHand hand) {
|
||||
var itemInHand = player.getItemInHand(hand);
|
||||
var fluidHandler = itemInHand.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = itemInHand.getCapability(Capabilities.Fluid.ITEM);
|
||||
if (fluidHandler != null) {
|
||||
if (fluidHandler.getFluidInTank(0).getAmount() < this.capacity) {
|
||||
var hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY);
|
||||
|
|
@ -158,13 +157,13 @@ public class WateringCanItem extends Item {
|
|||
var state = level.getBlockState(pos);
|
||||
|
||||
if (state.getFluidState().getType() == Fluids.WATER && state.getBlock() instanceof BucketPickup pickup) {
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
fluidHandler.fill(new FluidStack(Fluids.WATER, 1000), IFluidHandler.FluidAction.EXECUTE);
|
||||
pickup.pickupBlock(player, level, pos, state);
|
||||
pickup.getPickupSound(state).ifPresent(sound -> player.playSound(sound, 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
return level.isClientSide ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER;
|
||||
return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +188,7 @@ public class WateringCanItem extends Item {
|
|||
var useTicks = 72000 - remainingTicks;
|
||||
|
||||
if (useTicks >= STARTUP_TIME || living instanceof FakePlayer) {
|
||||
var fluidHandler = stack.getCapability(Capabilities.FluidHandler.ITEM);
|
||||
var fluidHandler = stack.getCapability(Capabilities.Fluid.ITEM);
|
||||
if (fluidHandler != null) {
|
||||
if (!fluidHandler.getFluidInTank(0).isEmpty()) {
|
||||
// do watering can
|
||||
|
|
@ -200,7 +199,7 @@ public class WateringCanItem extends Item {
|
|||
var pos = blockHit.getBlockPos();
|
||||
var state = level.getBlockState(pos);
|
||||
|
||||
if (!level.isClientSide) {
|
||||
if (!level.isClientSide()) {
|
||||
if (useTicks % WATERING_INTERVAL == 0) {
|
||||
tryWatering((ServerLevel) level, pos, state);
|
||||
|
||||
|
|
@ -231,17 +230,18 @@ public class WateringCanItem extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void releaseUsing(ItemStack stack, Level level, LivingEntity living, int timeCharged) {
|
||||
public boolean releaseUsing(ItemStack stack, Level level, LivingEntity living, int timeCharged) {
|
||||
if (timeCharged > STARTUP_TIME) {
|
||||
level.playLocalSound(living.getX(), living.getY(), living.getZ(), ESounds.WATERING_CAN_STOP.get(), living.getSoundSource(), 0.6f, 0.7f, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void tryWatering(ServerLevel level, BlockPos pos, BlockState state) {
|
||||
if (state.is(EBlockTags.WATERING_CAN_TICKABLE)) {
|
||||
if (state.is(BlockTags.SAPLINGS)) {
|
||||
if (level.random.nextInt(3) == 0) {
|
||||
state.randomTick(level, pos, level.random);
|
||||
if (level.getRandom().nextInt(3) == 0) {
|
||||
state.randomTick(level, pos, level.getRandom());
|
||||
level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, pos, 0);
|
||||
}
|
||||
} else if (state.getBlock() instanceof SugarCaneBlock block) {
|
||||
|
|
@ -251,9 +251,9 @@ public class WateringCanItem extends Item {
|
|||
}
|
||||
// randomTick only works on the top sugarcane block
|
||||
var topState = level.getBlockState(cursor.move(0, -1, 0));
|
||||
topState.randomTick(level, cursor, level.random);
|
||||
topState.randomTick(level, cursor, level.getRandom());
|
||||
} else {
|
||||
state.randomTick(level, pos, level.random);
|
||||
state.randomTick(level, pos, level.getRandom());
|
||||
}
|
||||
} else {
|
||||
if (BarrelBlockEntity.isHotFluid(state.getFluidState().getFluidType())) {
|
||||
|
|
@ -270,7 +270,7 @@ public class WateringCanItem extends Item {
|
|||
}
|
||||
|
||||
private static void hydrateFarmland(ServerLevel level, BlockPos pos, BlockState state) {
|
||||
var randomPos = pos.offset(level.random.nextIntBetweenInclusive(-1, 1), 0, level.random.nextIntBetweenInclusive(-1, 1));
|
||||
var randomPos = pos.offset(level.getRandom().nextIntBetweenInclusive(-1, 1), 0, level.getRandom().nextIntBetweenInclusive(-1, 1));
|
||||
|
||||
if (randomPos != pos) {
|
||||
pos = randomPos;
|
||||
|
|
@ -288,16 +288,16 @@ public class WateringCanItem extends Item {
|
|||
|
||||
protected void waterParticles(Level level, BlockPos pos, BlockState state) {
|
||||
if (level instanceof ServerLevel serverLevel) {
|
||||
double x = pos.getX() + 0.5 + level.random.nextGaussian() / 8f;
|
||||
double x = pos.getX() + 0.5 + level.getRandom().nextGaussian() / 8f;
|
||||
double y = pos.getY();
|
||||
double z = pos.getZ() + 0.5 + level.random.nextGaussian() / 8f;
|
||||
double z = pos.getZ() + 0.5 + level.getRandom().nextGaussian() / 8f;
|
||||
var collisionShape = state.getCollisionShape(level, pos);
|
||||
if (!collisionShape.isEmpty()) {
|
||||
y += collisionShape.max(Direction.Axis.Y);
|
||||
}
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
if (level.random.nextBoolean()) {
|
||||
if (level.getRandom().nextBoolean()) {
|
||||
serverLevel.sendParticles(ParticleTypes.RAIN, x + i * 0.33, y, z + j * 0.33, 2, 0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
|
|
@ -305,7 +305,6 @@ public class WateringCanItem extends Item {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
|
||||
consumer.accept(ClientExtensions.INSTANCE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class WideWateringCanItem extends WateringCanItem {
|
|||
protected void tryWatering(ServerLevel level, BlockPos pos, BlockState state) {
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
for (int j = -1; j <= 1; j++) {
|
||||
if (level.random.nextInt(3) != 0) {
|
||||
if (level.getRandom().nextInt(3) != 0) {
|
||||
var newPos = pos.offset(i, 0, j);
|
||||
var newState = state;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ public class CrookLootModifier extends LootModifier {
|
|||
|
||||
@Override
|
||||
protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
|
||||
var state = context.getParamOrNull(LootContextParams.BLOCK_STATE);
|
||||
var stack = context.getParamOrNull(LootContextParams.TOOL);
|
||||
var state = context.getOptionalParameter(LootContextParams.BLOCK_STATE);
|
||||
var stack = context.getOptionalParameter(LootContextParams.TOOL);
|
||||
|
||||
if (state != null && stack != null) {
|
||||
var rand = context.getRandom();
|
||||
|
|
@ -85,14 +85,14 @@ public class CrookLootModifier extends LootModifier {
|
|||
|
||||
private static List<ItemStack> reRollDrops(LootContext context, ItemStack nonCrook, BlockState state) {
|
||||
var builder = new LootParams.Builder(context.getLevel());
|
||||
builder.withParameter(LootContextParams.BLOCK_STATE, context.getParam(LootContextParams.BLOCK_STATE));
|
||||
builder.withParameter(LootContextParams.BLOCK_STATE, context.getParameter(LootContextParams.BLOCK_STATE));
|
||||
builder.withParameter(LootContextParams.TOOL, nonCrook);
|
||||
|
||||
if (context.hasParam(LootContextParams.THIS_ENTITY)) {
|
||||
builder.withParameter(LootContextParams.THIS_ENTITY, context.getParam(LootContextParams.THIS_ENTITY));
|
||||
if (context.hasParameter(LootContextParams.THIS_ENTITY)) {
|
||||
builder.withParameter(LootContextParams.THIS_ENTITY, context.getParameter(LootContextParams.THIS_ENTITY));
|
||||
}
|
||||
if (context.hasParam(LootContextParams.ORIGIN)) {
|
||||
builder.withParameter(LootContextParams.ORIGIN, context.getParam(LootContextParams.ORIGIN));
|
||||
if (context.hasParameter(LootContextParams.ORIGIN)) {
|
||||
builder.withParameter(LootContextParams.ORIGIN, context.getParameter(LootContextParams.ORIGIN));
|
||||
}
|
||||
return state.getDrops(builder);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class HammerLootModifier extends LootModifier {
|
|||
|
||||
@Override
|
||||
protected ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
|
||||
var state = context.getParamOrNull(LootContextParams.BLOCK_STATE);
|
||||
var state = context.getOptionalParameter(LootContextParams.BLOCK_STATE);
|
||||
|
||||
if (state == null) {
|
||||
return generatedLoot;
|
||||
|
|
@ -77,8 +77,8 @@ public class HammerLootModifier extends LootModifier {
|
|||
ObjectArrayList<ItemStack> newLoot = new ObjectArrayList<>();
|
||||
var resultAmount = recipe.resultAmount.getInt(context);
|
||||
|
||||
if (!itemForm.builtInRegistryHolder().is(this.fortuneBlacklistTag) && context.hasParam(LootContextParams.TOOL)) {
|
||||
var hammer = context.getParam(LootContextParams.TOOL);
|
||||
if (!itemForm.builtInRegistryHolder().is(this.fortuneBlacklistTag) && context.hasParameter(LootContextParams.TOOL)) {
|
||||
var hammer = context.getParameter(LootContextParams.TOOL);
|
||||
// fortune handling; more likely to boost drops if there are none to begin with
|
||||
resultAmount += calculateFortuneBonus(context.getLevel().registryAccess(), hammer, context.getRandom(), resultAmount == 0);
|
||||
}
|
||||
|
|
@ -129,4 +129,3 @@ public class HammerLootModifier extends LootModifier {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,11 @@ package thedarkcolour.exdeorum.loot;
|
|||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.world.level.storage.TagValueOutput;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
|
|
@ -39,9 +41,11 @@ public class MachineLootFunction extends LootItemConditionalFunction {
|
|||
|
||||
@Override
|
||||
protected ItemStack run(ItemStack stack, LootContext ctx) {
|
||||
BlockEntity blockEntity = ctx.getParamOrNull(LootContextParams.BLOCK_ENTITY);
|
||||
if (blockEntity != null) {
|
||||
blockEntity.saveToItem(stack, ctx.getLevel().registryAccess());
|
||||
BlockEntity blockEntity = ctx.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
|
||||
if (blockEntity != null && stack.getItem() instanceof BlockItem) {
|
||||
var output = TagValueOutput.createWithContext(ProblemReporter.DISCARDING, ctx.getLevel().registryAccess());
|
||||
blockEntity.saveCustomOnly(output);
|
||||
BlockItem.setBlockEntityData(stack, blockEntity.getType(), output);
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ public class VisualUpdateTracker {
|
|||
public static void sendVisualUpdate(EBlockEntity blockEntity) {
|
||||
var level = blockEntity.getLevel();
|
||||
|
||||
if (level != null && !level.isClientSide) {
|
||||
if (level != null && !level.isClientSide()) {
|
||||
Map<ChunkPos, Set<BlockPos>> chunkUpdates = UPDATES.computeIfAbsent(level.dimension(), key -> new HashMap<>());
|
||||
chunkUpdates.computeIfAbsent(new ChunkPos(blockEntity.getBlockPos()), key -> new HashSet<>()).add(blockEntity.getBlockPos());
|
||||
chunkUpdates.computeIfAbsent(new ChunkPos(blockEntity.getBlockPos().getX() >> 4, blockEntity.getBlockPos().getZ() >> 4), key -> new HashSet<>()).add(blockEntity.getBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ public class EBiomeTags {
|
|||
|
||||
static {
|
||||
// Vanilla
|
||||
addTreeTag("oak_tree_biomes", TreeFeatures.OAK_BEES_005.location());
|
||||
addTreeTag("spruce_tree_biomes", TreeFeatures.SPRUCE.location());
|
||||
addTreeTag("birch_tree_biomes", TreeFeatures.BIRCH_BEES_002.location());
|
||||
addTreeTag("jungle_tree_biomes", TreeFeatures.JUNGLE_TREE_NO_VINE.location());
|
||||
addTreeTag("acacia_tree_biomes", TreeFeatures.ACACIA.location());
|
||||
addTreeTag("cherry_tree_biomes", TreeFeatures.CHERRY_BEES_005.location());
|
||||
addTreeTag("dark_oak_tree_biomes", TreeFeatures.DARK_OAK.location());
|
||||
addTreeTag("mangrove_tree_biomes", TreeFeatures.MANGROVE.location());
|
||||
addTreeTag("oak_tree_biomes", TreeFeatures.OAK_BEES_005.identifier());
|
||||
addTreeTag("spruce_tree_biomes", TreeFeatures.SPRUCE.identifier());
|
||||
addTreeTag("birch_tree_biomes", TreeFeatures.BIRCH_BEES_002.identifier());
|
||||
addTreeTag("jungle_tree_biomes", TreeFeatures.JUNGLE_TREE_NO_VINE.identifier());
|
||||
addTreeTag("acacia_tree_biomes", TreeFeatures.ACACIA.identifier());
|
||||
addTreeTag("cherry_tree_biomes", TreeFeatures.CHERRY_BEES_005.identifier());
|
||||
addTreeTag("dark_oak_tree_biomes", TreeFeatures.DARK_OAK.identifier());
|
||||
addTreeTag("mangrove_tree_biomes", TreeFeatures.MANGROVE.identifier());
|
||||
// Bop tags
|
||||
addTreeTag("flowering_oak_tree_biomes", Identifier.fromNamespaceAndPath(ModIds.BIOMES_O_PLENTY, "flowering_oak_tree_bees"));
|
||||
addTreeTag("mahogany_tree_biomes", Identifier.fromNamespaceAndPath(ModIds.BIOMES_O_PLENTY, "mahogany_tree"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user