mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
some work on the port
This commit is contained in:
parent
0d638e9e1e
commit
6525ff5d25
19 changed files with 553 additions and 629 deletions
|
@ -21,7 +21,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -37,7 +37,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.Property;
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
@ -46,8 +46,6 @@ import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
|
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||||
import top.theillusivec4.curios.api.CuriosApi;
|
|
||||||
import top.theillusivec4.curios.api.SlotResult;
|
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -116,7 +114,7 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
|
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
|
||||||
return nbt ? ItemStack.isSameItemSameTags(first, second) : ItemStack.isSameItem(first, second);
|
return nbt ? ItemStack.isSameItemSameComponents(first, second) : ItemStack.isSameItem(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ -132,34 +130,34 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void renderWeirdBox(VertexConsumer buffer, double x, double y, double z, double width, double height, double depth, float r, float g, float b, float a) {
|
public static void renderWeirdBox(VertexConsumer buffer, float x, float y, float z, float width, float height, float depth, float r, float g, float b, float a) {
|
||||||
buffer.vertex(x, y + height, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y + height, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y + height, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y + height, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y + height, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y + height, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y + height, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y + height, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y + height, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y + height, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y + height, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y + height, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y + height, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y + height, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y + height, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y + height, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y + height, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y + height, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y + height, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y + height, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y + height, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y + height, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y + height, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y + height, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y, z).setColor(r, g, b, a);
|
||||||
buffer.vertex(x + width, y, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x + width, y, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y, z + depth).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y, z + depth).setColor(r, g, b, a);
|
||||||
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
|
buffer.addVertex(x, y, z).setColor(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
public static ItemInteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
||||||
var tile = player.level().getBlockEntity(pos);
|
var tile = player.level().getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityImpl) {
|
if (tile instanceof BlockEntityImpl) {
|
||||||
var handler = (IItemHandlerModifiable) tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
var handler = (IItemHandlerModifiable) tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
@ -173,7 +171,7 @@ public final class Helper {
|
||||||
SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
|
SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
|
||||||
if (!player.level().isClientSide)
|
if (!player.level().isClientSide)
|
||||||
player.setItemInHand(hand, remain);
|
player.setItemInHand(hand, remain);
|
||||||
return InteractionResult.SUCCESS;
|
return ItemInteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,11 +187,11 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
handler.setStackInSlot(slot, ItemStack.EMPTY);
|
handler.setStackInSlot(slot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
return ItemInteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return InteractionResult.CONSUME;
|
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICapabilityProvider<ItemStack, Void, IAuraRecharge> makeRechargeProvider(boolean needsSelected) {
|
public static ICapabilityProvider<ItemStack, Void, IAuraRecharge> makeRechargeProvider(boolean needsSelected) {
|
||||||
|
@ -215,7 +213,7 @@ public final class Helper {
|
||||||
|
|
||||||
public static BlockState getStateFromString(String raw) {
|
public static BlockState getStateFromString(String raw) {
|
||||||
var split = raw.split("\\[");
|
var split = raw.split("\\[");
|
||||||
var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(split[0]));
|
var block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(split[0]));
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
var state = block.defaultBlockState();
|
var state = block.defaultBlockState();
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
@ -284,7 +282,7 @@ public final class Helper {
|
||||||
for (var entry : clazz.getFields()) {
|
for (var entry : clazz.getFields()) {
|
||||||
if (!Modifier.isStatic(entry.getModifiers()))
|
if (!Modifier.isStatic(entry.getModifiers()))
|
||||||
continue;
|
continue;
|
||||||
var location = new ResourceLocation(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
|
var location = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
|
||||||
if (!registry.containsKey(location)) {
|
if (!registry.containsKey(location)) {
|
||||||
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry");
|
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry");
|
||||||
continue;
|
continue;
|
||||||
|
@ -298,14 +296,15 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
||||||
if (Compat.hasCompat("curios")) {
|
// TODO curios?
|
||||||
|
/* if (Compat.hasCompat("curios")) {
|
||||||
var inventory = CuriosApi.getCuriosInventory(player);
|
var inventory = CuriosApi.getCuriosInventory(player);
|
||||||
if (inventory.isPresent()) {
|
if (inventory.isPresent()) {
|
||||||
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
|
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
|
||||||
if (stack.isPresent())
|
if (stack.isPresent())
|
||||||
return stack.get();
|
return stack.get();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
||||||
for (var i = 0; i < invSize; i++) {
|
for (var i = 0; i < invSize; i++) {
|
||||||
var slot = player.getInventory().getItem(i);
|
var slot = player.getInventory().getItem(i);
|
||||||
|
|
|
@ -52,10 +52,10 @@ public final class NaturesAuraAPI {
|
||||||
* A map of all {@link IAuraType} instances which are types of Aura present in different types of levels. {@link BasicAuraType} instances can be easily registered using {@link BasicAuraType#register()}.
|
* A map of all {@link IAuraType} instances which are types of Aura present in different types of levels. {@link BasicAuraType} instances can be easily registered using {@link BasicAuraType#register()}.
|
||||||
*/
|
*/
|
||||||
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
|
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
|
||||||
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register();
|
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register();
|
||||||
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register();
|
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register();
|
||||||
public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "end"), Level.END, 0x302624, 0).register();
|
public static final BasicAuraType TYPE_END = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "end"), Level.END, 0x302624, 0).register();
|
||||||
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
|
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
|
||||||
/**
|
/**
|
||||||
* A map of all {@link IDrainSpotEffect} suppliers which are effects that happen passively at every spot that Aura has been drained from in the level. These effects include things like vegetational increase and natural decay. To register your own drain spot effects, just add a supplier for them to this map, and they will automatically be executed once a second for every drain spot currently loaded.
|
* A map of all {@link IDrainSpotEffect} suppliers which are effects that happen passively at every spot that Aura has been drained from in the level. These effects include things like vegetational increase and natural decay. To register your own drain spot effects, just add a supplier for them to this map, and they will automatically be executed once a second for every drain spot currently loaded.
|
||||||
*/
|
*/
|
||||||
|
@ -87,15 +87,15 @@ public final class NaturesAuraAPI {
|
||||||
/**
|
/**
|
||||||
* The capability for any item that stores Aura in the form of an {@link IAuraContainer}
|
* The capability for any item that stores Aura in the form of an {@link IAuraContainer}
|
||||||
*/
|
*/
|
||||||
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_ITEM_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container_item"), IAuraContainer.class);
|
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_ITEM_CAPABILITY = ItemCapability.createVoid(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "aura_container_item"), IAuraContainer.class);
|
||||||
/**
|
/**
|
||||||
* The capability for any block that stores Aura in the form of an {@link IAuraContainer}
|
* The capability for any block that stores Aura in the form of an {@link IAuraContainer}
|
||||||
*/
|
*/
|
||||||
public static final BlockCapability<IAuraContainer, Direction> AURA_CONTAINER_BLOCK_CAPABILITY = BlockCapability.create(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container_block"), IAuraContainer.class, Direction.class);
|
public static final BlockCapability<IAuraContainer, Direction> AURA_CONTAINER_BLOCK_CAPABILITY = BlockCapability.create(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "aura_container_block"), IAuraContainer.class, Direction.class);
|
||||||
/**
|
/**
|
||||||
* The capability for any item that can be recharged from an Aura storage container like the Aura Cache in the form of {@link IAuraRecharge} by a player holding it in their hand
|
* The capability for any item that can be recharged from an Aura storage container like the Aura Cache in the form of {@link IAuraRecharge} by a player holding it in their hand
|
||||||
*/
|
*/
|
||||||
public static final ItemCapability<IAuraRecharge, Void> AURA_RECHARGE_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_recharge"), IAuraRecharge.class);
|
public static final ItemCapability<IAuraRecharge, Void> AURA_RECHARGE_CAPABILITY = ItemCapability.createVoid(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "aura_recharge"), IAuraRecharge.class);
|
||||||
/**
|
/**
|
||||||
* The capability that any chunk in a level has to store Aura in it. As this is only applicable to chunks and all chunks in the level automatically get assigned this capability, using it directly is not necessary for addon developers. To retrieve this capability from any chunk, use the helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, BlockPos)}.
|
* The capability that any chunk in a level has to store Aura in it. As this is only applicable to chunks and all chunks in the level automatically get assigned this capability, using it directly is not necessary for addon developers. To retrieve this capability from any chunk, use the helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, BlockPos)}.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,9 +20,11 @@ import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.BaseRailBlock;
|
import net.minecraft.world.level.block.BaseRailBlock;
|
||||||
|
@ -35,10 +37,8 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||||
import net.minecraft.world.level.block.state.properties.Property;
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import net.minecraft.world.level.block.state.properties.RailShape;
|
import net.minecraft.world.level.block.state.properties.RailShape;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
|
import net.minecraft.world.level.portal.DimensionTransition;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.neoforge.common.util.ITeleporter;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICustomBlockState, ICustomItemModel {
|
public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICustomBlockState, ICustomItemModel {
|
||||||
|
|
||||||
|
@ -66,20 +66,18 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
||||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
||||||
var stack = player.getItemInHand(hand);
|
|
||||||
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
|
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
|
||||||
if (!levelIn.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
var goalPos = this.getGoalCoords(levelIn, pos);
|
var goalPos = this.getGoalCoords(level, pos);
|
||||||
var data = new CompoundTag();
|
var data = new CompoundTag();
|
||||||
data.putString("dim", this.goalDim.location().toString());
|
data.putString("dim", this.goalDim.location().toString());
|
||||||
data.putLong("pos", goalPos.asLong());
|
data.putLong("pos", goalPos.asLong());
|
||||||
PacketHandler.sendTo(player, new PacketClient(0, data));
|
PacketHandler.sendTo(player, new PacketClient(0, data));
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
return ItemInteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return InteractionResult.FAIL;
|
return ItemInteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,21 +93,9 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
||||||
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
|
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
|
||||||
level.playSound(null, pos, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1F, 1F);
|
level.playSound(null, pos, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1F, 1F);
|
||||||
|
|
||||||
var goalCoords = this.getGoalCoords(level, pos);
|
// TODO test if this new dimension change works!
|
||||||
cart.changeDimension(level.getServer().getLevel(this.goalDim), new ITeleporter() {
|
var goalCoords = this.getGoalCoords(level, pos).getCenter();
|
||||||
@Override
|
cart.changeDimension(new DimensionTransition(level.getServer().getLevel(this.goalDim), goalCoords, cart.getDeltaMovement(), cart.getYRot(), cart.getXRot(), DimensionTransition.PLAY_PORTAL_SOUND));
|
||||||
public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function<Boolean, Entity> repositionEntity) {
|
|
||||||
// repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy
|
|
||||||
entity.level().getProfiler().popPush("reloading");
|
|
||||||
var result = entity.getType().create(destLevel);
|
|
||||||
if (result != null) {
|
|
||||||
result.restoreFrom(entity);
|
|
||||||
destLevel.addDuringTeleport(result);
|
|
||||||
result.moveTo(goalCoords, yaw, result.getXRot());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
|
var spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
|
||||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
|
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
|
||||||
|
@ -177,4 +163,5 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName());
|
generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.neoforge.event.tick.EntityTickEvent;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -52,7 +53,7 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDragonTick(LivingEvent.LivingTickEvent event) {
|
public void onDragonTick(EntityTickEvent.Pre event) {
|
||||||
var living = event.getEntity();
|
var living = event.getEntity();
|
||||||
if (living.level().isClientSide || !(living instanceof EnderDragon dragon))
|
if (living.level().isClientSide || !(living instanceof EnderDragon dragon))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.level.SaplingGrowTreeEvent;
|
import net.neoforged.neoforge.event.level.BlockGrowFeatureEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||||
|
@ -31,7 +31,7 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
public void onTreeGrow(BlockGrowFeatureEvent event) {
|
||||||
var level = event.getLevel();
|
var level = event.getLevel();
|
||||||
var pos = event.getPos();
|
var pos = event.getPos();
|
||||||
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
||||||
|
@ -86,4 +86,5 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,9 @@ import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.neoforge.common.util.TriState;
|
||||||
|
import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent;
|
||||||
|
|
||||||
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||||
|
|
||||||
|
@ -26,10 +27,10 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPickup(EntityItemPickupEvent event) {
|
public void onPickup(ItemEntityPickupEvent.Pre event) {
|
||||||
var player = event.getEntity();
|
var player = event.getPlayer();
|
||||||
if (player != null && !player.isShiftKeyDown()) {
|
if (player != null && !player.isShiftKeyDown()) {
|
||||||
var item = event.getItem();
|
var item = event.getItemEntity();
|
||||||
var pos = item.blockPosition();
|
var pos = item.blockPosition();
|
||||||
Helper.getBlockEntitiesInArea(item.level(), pos, 8, tile -> {
|
Helper.getBlockEntitiesInArea(item.level(), pos, 8, tile -> {
|
||||||
if (!(tile instanceof BlockEntityPickupStopper stopper))
|
if (!(tile instanceof BlockEntityPickupStopper stopper))
|
||||||
|
@ -41,7 +42,7 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
|
if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
event.setCanceled(true);
|
event.setCanPickup(TriState.FALSE);
|
||||||
|
|
||||||
if (item.level().getGameTime() % 3 == 0)
|
if (item.level().getGameTime() % 3 == 0)
|
||||||
PacketHandler.sendToAllAround(item.level(), pos, 32,
|
PacketHandler.sendToAllAround(item.level(), pos, 32,
|
||||||
|
@ -76,4 +77,5 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,25 +10,25 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.core.Position;
|
import net.minecraft.core.dispenser.BlockSource;
|
||||||
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
|
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||||
import net.minecraft.world.entity.projectile.Projectile;
|
|
||||||
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
||||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.ProjectileItem.DispenseConfig;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.DispenserBlock;
|
import net.minecraft.world.level.block.DispenserBlock;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
|
||||||
import net.neoforged.neoforge.event.entity.ProjectileImpactEvent;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
||||||
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
|
import net.neoforged.neoforge.event.entity.ProjectileImpactEvent;
|
||||||
|
|
||||||
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
|
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
|
||||||
|
|
||||||
|
@ -36,23 +36,34 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of().strength(2.5F).sound(SoundType.STONE));
|
super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of().strength(2.5F).sound(SoundType.STONE));
|
||||||
|
|
||||||
NeoForge.EVENT_BUS.register(this);
|
NeoForge.EVENT_BUS.register(this);
|
||||||
DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() {
|
DispenserBlock.registerBehavior(Items.ENDER_PEARL, new DefaultDispenseItemBehavior() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
protected ItemStack execute(BlockSource blockSource, ItemStack item) {
|
||||||
var ret = new ThrownEnderpearl(EntityType.ENDER_PEARL, levelIn);
|
Level level = blockSource.level();
|
||||||
ret.setPos(position.x(), position.y(), position.z());
|
var direction = blockSource.state().getValue(DispenserBlock.FACING);
|
||||||
return ret;
|
var position = DispenseConfig.DEFAULT.positionFunction().getDispensePosition(blockSource, direction);
|
||||||
|
var projectile = new ThrownEnderpearl(EntityType.ENDER_PEARL, level);
|
||||||
|
projectile.setPos(position.x(), position.y(), position.z());
|
||||||
|
projectile.shoot(direction.getStepX(), direction.getStepY(), direction.getStepZ(), DispenseConfig.DEFAULT.power(), DispenseConfig.DEFAULT.uncertainty());
|
||||||
|
level.addFreshEntity(projectile);
|
||||||
|
item.shrink(1);
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
DispenserBlock.registerBehavior(Items.TRIDENT, new AbstractProjectileDispenseBehavior() {
|
DispenserBlock.registerBehavior(Items.TRIDENT, new DefaultDispenseItemBehavior() {
|
||||||
@Override
|
@Override
|
||||||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
protected ItemStack execute(BlockSource blockSource, ItemStack item) {
|
||||||
var ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
|
Level level = blockSource.level();
|
||||||
ret.setPos(position.x(), position.y(), position.z());
|
var direction = blockSource.state().getValue(DispenserBlock.FACING);
|
||||||
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "pickupItemStack");
|
var position = DispenseConfig.DEFAULT.positionFunction().getDispensePosition(blockSource, direction);
|
||||||
ret.pickup = AbstractArrow.Pickup.ALLOWED;
|
var projectile = new ThrownTrident(EntityType.TRIDENT, level);
|
||||||
return ret;
|
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, projectile, item.copy(), "pickupItemStack");
|
||||||
|
projectile.pickup = AbstractArrow.Pickup.ALLOWED;
|
||||||
|
projectile.setPos(position.x(), position.y(), position.z());
|
||||||
|
projectile.shoot(direction.getStepX(), direction.getStepY(), direction.getStepZ(), DispenseConfig.DEFAULT.power(), DispenseConfig.DEFAULT.uncertainty());
|
||||||
|
level.addFreshEntity(projectile);
|
||||||
|
item.shrink(1);
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,4 +114,5 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
public void registerTESR() {
|
public void registerTESR() {
|
||||||
BlockEntityRenderers.register(ModBlockEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
|
BlockEntityRenderers.register(ModBlockEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
@ -26,7 +26,7 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.level.SaplingGrowTreeEvent;
|
import net.neoforged.neoforge.event.level.BlockGrowFeatureEvent;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -53,7 +53,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
public void onTreeGrow(BlockGrowFeatureEvent event) {
|
||||||
var level = event.getLevel();
|
var level = event.getLevel();
|
||||||
var pos = event.getPos();
|
var pos = event.getPos();
|
||||||
if (!level.isClientSide() && level instanceof Level) {
|
if (!level.isClientSide() && level instanceof Level) {
|
||||||
|
@ -99,9 +99,8 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
||||||
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
return Helper.putStackOnTile(player, hand, pos, 0, true);
|
||||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
import net.minecraft.world.entity.AreaEffectCloud;
|
||||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
import net.minecraft.world.item.alchemy.PotionContents;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity {
|
public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity {
|
||||||
|
|
||||||
|
private static final Field POTION_CONTENTS_FIELD = ObfuscationReflectionHelper.findField(AreaEffectCloud.class, "potionContents");
|
||||||
|
|
||||||
public BlockEntityPotionGenerator(BlockPos pos, BlockState state) {
|
public BlockEntityPotionGenerator(BlockPos pos, BlockState state) {
|
||||||
super(ModBlockEntities.POTION_GENERATOR, pos, state);
|
super(ModBlockEntities.POTION_GENERATOR, pos, state);
|
||||||
}
|
}
|
||||||
|
@ -27,12 +33,17 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!addedOne) {
|
if (!addedOne) {
|
||||||
var type = cloud.getPotion();
|
PotionContents type;
|
||||||
if (type == null)
|
try {
|
||||||
|
// TODO check if this new private value getter works
|
||||||
|
type = (PotionContents) BlockEntityPotionGenerator.POTION_CONTENTS_FIELD.get(cloud);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (var effect : type.getEffects()) {
|
for (var effect : type.getAllEffects()) {
|
||||||
var potion = effect.getEffect();
|
var potion = effect.getEffect().value();
|
||||||
if (!potion.isBeneficial() || potion.isInstantenous()) {
|
if (!potion.isBeneficial() || potion.isInstantenous()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +55,7 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
|
||||||
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.POTION_GEN,
|
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.POTION_GEN,
|
||||||
PotionUtils.getColor(type), canGen ? 1 : 0));
|
type.getColor(), canGen ? 1 : 0));
|
||||||
|
|
||||||
addedOne = true;
|
addedOne = true;
|
||||||
break;
|
break;
|
||||||
|
@ -66,4 +77,5 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
||||||
public boolean wantsLimitRemover() {
|
public boolean wantsLimitRemover() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,10 +132,10 @@ public class AuraChunk implements IAuraChunk {
|
||||||
this.drainSpots.put(spot.pos, spot);
|
this.drainSpots.put(spot.pos, spot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpots(Collection<DrainSpot> spots) {
|
public void setSpots(Collection<CompoundTag> spots) {
|
||||||
this.drainSpots.clear();
|
this.drainSpots.clear();
|
||||||
for (var spot : spots)
|
for (var spot : spots)
|
||||||
this.addDrainSpot(spot);
|
this.addDrainSpot(new DrainSpot(spot));
|
||||||
this.addOrRemoveAsActive();
|
this.addOrRemoveAsActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// TODO curios?
|
||||||
|
/*
|
||||||
package de.ellpeck.naturesaura.compat;
|
package de.ellpeck.naturesaura.compat;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -88,3 +90,4 @@ public class CuriosCompat implements ICompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||||
import net.minecraft.core.HolderSet;
|
import net.minecraft.core.HolderSet;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.data.worldgen.BootstapContext;
|
import net.minecraft.data.worldgen.BootstrapContext;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.BiomeTags;
|
import net.minecraft.tags.BiomeTags;
|
||||||
|
@ -23,10 +23,10 @@ public class BiomeModifiers {
|
||||||
public static final ResourceKey<BiomeModifier> AURA_MUSHROOM = BiomeModifiers.createKey("aura_mushroom");
|
public static final ResourceKey<BiomeModifier> AURA_MUSHROOM = BiomeModifiers.createKey("aura_mushroom");
|
||||||
|
|
||||||
private static ResourceKey<BiomeModifier> createKey(String id) {
|
private static ResourceKey<BiomeModifier> createKey(String id) {
|
||||||
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(NaturesAura.MOD_ID, id));
|
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bootstrap(BootstapContext<BiomeModifier> context) {
|
public static void bootstrap(BootstrapContext<BiomeModifier> context) {
|
||||||
var biomeGetter = context.lookup(Registries.BIOME);
|
var biomeGetter = context.lookup(Registries.BIOME);
|
||||||
var placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
var placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.data.loot.LootTableProvider;
|
||||||
import net.minecraft.data.registries.VanillaRegistries;
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
||||||
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
|
@ -22,7 +23,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
|
||||||
public final class ModData {
|
public final class ModData {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.neoforged.bus.api.EventPriority;
|
import net.neoforged.bus.api.EventPriority;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.neoforge.event.tick.EntityTickEvent;
|
||||||
|
|
||||||
public class ItemPetReviver extends ItemImpl {
|
public class ItemPetReviver extends ItemImpl {
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ public class ItemPetReviver extends ItemImpl {
|
||||||
private static class Events {
|
private static class Events {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityTick(LivingEvent.LivingTickEvent event) {
|
public void onEntityTick(EntityTickEvent event) {
|
||||||
var entity = event.getEntity();
|
var entity = event.getEntity();
|
||||||
if (entity.level().isClientSide || entity.level().getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable))
|
if (entity.level().isClientSide || entity.level().getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable))
|
||||||
return;
|
return;
|
||||||
|
@ -129,5 +130,7 @@ public class ItemPetReviver extends ItemImpl {
|
||||||
owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY));
|
owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY));
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,56 +4,36 @@ import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||||
import de.ellpeck.naturesaura.events.ClientEvents;
|
import de.ellpeck.naturesaura.events.ClientEvents;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class PacketAuraChunk implements CustomPacketPayload {
|
public record PacketAuraChunk(int chunkX, int chunkZ, Collection<CompoundTag> drainSpots) implements CustomPacketPayload {
|
||||||
|
|
||||||
public static final ResourceLocation ID = new ResourceLocation(NaturesAura.MOD_ID, "aura_chunk");
|
public static final Type<PacketAuraChunk> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "aura_chunk"));
|
||||||
|
public static final StreamCodec<RegistryFriendlyByteBuf, PacketAuraChunk> CODEC = StreamCodec.composite(
|
||||||
private final int chunkX;
|
ByteBufCodecs.INT, PacketAuraChunk::chunkX,
|
||||||
private final int chunkZ;
|
ByteBufCodecs.INT, PacketAuraChunk::chunkZ,
|
||||||
private final Collection<AuraChunk.DrainSpot> drainSpots;
|
ByteBufCodecs.collection(ArrayList::new, ByteBufCodecs.COMPOUND_TAG), PacketAuraChunk::drainSpots,
|
||||||
|
PacketAuraChunk::new);
|
||||||
public PacketAuraChunk(int chunkX, int chunkZ, Collection<AuraChunk.DrainSpot> drainSpots) {
|
|
||||||
this.chunkX = chunkX;
|
|
||||||
this.chunkZ = chunkZ;
|
|
||||||
this.drainSpots = drainSpots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketAuraChunk(FriendlyByteBuf buf) {
|
|
||||||
this.chunkX = buf.readInt();
|
|
||||||
this.chunkZ = buf.readInt();
|
|
||||||
|
|
||||||
this.drainSpots = new ArrayList<>();
|
|
||||||
var amount = buf.readInt();
|
|
||||||
for (var i = 0; i < amount; i++)
|
|
||||||
this.drainSpots.add(new AuraChunk.DrainSpot(buf.readNbt()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(FriendlyByteBuf buf) {
|
public Type<? extends CustomPacketPayload> type() {
|
||||||
buf.writeInt(this.chunkX);
|
return PacketAuraChunk.TYPE;
|
||||||
buf.writeInt(this.chunkZ);
|
|
||||||
|
|
||||||
buf.writeInt(this.drainSpots.size());
|
|
||||||
for (var entry : this.drainSpots)
|
|
||||||
buf.writeNbt(entry.serializeNBT());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void onMessage(PacketAuraChunk message, IPayloadContext ctx) {
|
||||||
public ResourceLocation id() {
|
ClientEvents.PENDING_AURA_CHUNKS.add(message);
|
||||||
return PacketAuraChunk.ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onMessage(PacketAuraChunk message, PlayPayloadContext ctx) {
|
|
||||||
ctx.workHandler().execute(() -> ClientEvents.PENDING_AURA_CHUNKS.add(message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tryHandle(Level level) {
|
public boolean tryHandle(Level level) {
|
||||||
|
@ -62,8 +42,6 @@ public class PacketAuraChunk implements CustomPacketPayload {
|
||||||
if (chunk.isEmpty())
|
if (chunk.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
||||||
if (auraChunk == null)
|
|
||||||
return false;
|
|
||||||
auraChunk.setSpots(this.drainSpots);
|
auraChunk.setSpots(this.drainSpots);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -8,63 +8,46 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
|
|
||||||
public class PacketClient implements CustomPacketPayload {
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public static final ResourceLocation ID = new ResourceLocation(NaturesAura.MOD_ID, "client");
|
public record PacketClient(int packetType, CompoundTag data) implements CustomPacketPayload {
|
||||||
|
|
||||||
private final int type;
|
public static final Type<PacketClient> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "client"));
|
||||||
private final CompoundTag data;
|
public static final StreamCodec<RegistryFriendlyByteBuf, PacketClient> CODEC = StreamCodec.composite(
|
||||||
|
ByteBufCodecs.INT, PacketClient::packetType,
|
||||||
public PacketClient(int type, CompoundTag data) {
|
ByteBufCodecs.COMPOUND_TAG, PacketClient::data,
|
||||||
this.type = type;
|
PacketClient::new);
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketClient(FriendlyByteBuf buf) {
|
|
||||||
this.type = buf.readByte();
|
|
||||||
this.data = buf.readNbt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(FriendlyByteBuf buf) {
|
public Type<? extends CustomPacketPayload> type() {
|
||||||
buf.writeByte(this.type);
|
return PacketClient.TYPE;
|
||||||
buf.writeNbt(this.data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void onMessage(PacketClient message, IPayloadContext ctx) {
|
||||||
public ResourceLocation id() {
|
|
||||||
return PacketClient.ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("Convert2Lambda")
|
|
||||||
public static void onMessage(PacketClient message, PlayPayloadContext ctx) {
|
|
||||||
ctx.workHandler().execute(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
var mc = Minecraft.getInstance();
|
var mc = Minecraft.getInstance();
|
||||||
if (mc.level != null) {
|
if (mc.level != null) {
|
||||||
switch (message.type) {
|
switch (message.packetType) {
|
||||||
case 0: // dimension rail visualization
|
case 0: // dimension rail visualization
|
||||||
var goalDim = new ResourceLocation(message.data.getString("dim"));
|
var goalDim = ResourceLocation.parse(message.data.getString("dim"));
|
||||||
var goalPos = BlockPos.of(message.data.getLong("pos"));
|
var goalPos = BlockPos.of(message.data.getLong("pos"));
|
||||||
ItemRangeVisualizer.visualize(mc.player, ItemRangeVisualizer.VISUALIZED_RAILS, goalDim, goalPos);
|
ItemRangeVisualizer.visualize(mc.player, ItemRangeVisualizer.VISUALIZED_RAILS, goalDim, goalPos);
|
||||||
case 1:
|
case 1:
|
||||||
var entity = mc.level.getEntity(message.data.getInt("id"));
|
var entity = mc.level.getEntity(message.data.getInt("id"));
|
||||||
mc.particleEngine.createTrackingEmitter(entity, ParticleTypes.TOTEM_OF_UNDYING, 30);
|
mc.particleEngine.createTrackingEmitter(entity, ParticleTypes.TOTEM_OF_UNDYING, 30);
|
||||||
mc.level.playLocalSound(entity.getX(), entity.getY(), entity.getZ(), SoundEvents.TOTEM_USE, entity.getSoundSource(), 1.0F, 1.0F, false);
|
mc.level.playLocalSound(entity.getX(), entity.getY(), entity.getZ(), SoundEvents.TOTEM_USE, entity.getSoundSource(), 1.0F, 1.0F, false);
|
||||||
if (entity == mc.player) {
|
if (entity == mc.player)
|
||||||
mc.gameRenderer.displayItemActivation(new ItemStack(ModItems.DEATH_RING));
|
mc.gameRenderer.displayItemActivation(new ItemStack(ModItems.DEATH_RING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,33 +3,34 @@ package de.ellpeck.naturesaura.packet;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.Mod.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod.EventBusSubscriber.Bus;
|
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||||
|
|
||||||
@EventBusSubscriber(bus = Bus.MOD)
|
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
|
||||||
public final class PacketHandler {
|
public final class PacketHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPayloadRegister(RegisterPayloadHandlerEvent event) {
|
public static void onPayloadRegister(RegisterPayloadHandlersEvent event) {
|
||||||
var registrar = event.registrar(NaturesAura.MOD_ID);
|
var registrar = event.registrar(NaturesAura.MOD_ID);
|
||||||
registrar.play(PacketAuraChunk.ID, PacketAuraChunk::new, PacketAuraChunk::onMessage);
|
registrar.playBidirectional(PacketAuraChunk.TYPE, PacketAuraChunk.CODEC, PacketAuraChunk::onMessage);
|
||||||
registrar.play(PacketClient.ID, PacketClient::new, PacketClient::onMessage);
|
registrar.playBidirectional(PacketClient.TYPE, PacketClient.CODEC, PacketClient::onMessage);
|
||||||
registrar.play(PacketParticles.ID, PacketParticles::new, PacketParticles::onMessage);
|
registrar.playBidirectional(PacketParticles.TYPE, PacketParticles.CODEC, PacketParticles::onMessage);
|
||||||
registrar.play(PacketParticleStream.ID, PacketParticleStream::new, PacketParticleStream::onMessage);
|
registrar.playBidirectional(PacketParticleStream.TYPE, PacketParticleStream.CODEC, PacketParticleStream::onMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToAllLoaded(Level level, BlockPos pos, CustomPacketPayload message) {
|
public static void sendToAllLoaded(Level level, BlockPos pos, CustomPacketPayload message) {
|
||||||
PacketDistributor.TRACKING_CHUNK.with(level.getChunkAt(pos)).send(message);
|
PacketDistributor.sendToPlayersTrackingChunk((ServerLevel) level, new ChunkPos(pos), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToAllAround(Level level, BlockPos pos, int range, CustomPacketPayload message) {
|
public static void sendToAllAround(Level level, BlockPos pos, int range, CustomPacketPayload message) {
|
||||||
PacketDistributor.NEAR.with(new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, level.dimension())).send(message);
|
PacketDistributor.sendToPlayersNear((ServerLevel) level, null, pos.getX(), pos.getY(), pos.getZ(), range, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTo(Player player, CustomPacketPayload message) {
|
public static void sendTo(Player player, CustomPacketPayload message) {
|
||||||
|
|
|
@ -2,74 +2,39 @@ package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
public class PacketParticleStream implements CustomPacketPayload {
|
public record PacketParticleStream(Vector3f start, Vector3f end, float speed, int color, float scale) implements CustomPacketPayload {
|
||||||
|
|
||||||
public static final ResourceLocation ID = new ResourceLocation(NaturesAura.MOD_ID, "particle_stream");
|
public static final Type<PacketParticleStream> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "particle_stream"));
|
||||||
|
public static final StreamCodec<RegistryFriendlyByteBuf, PacketParticleStream> CODEC = StreamCodec.composite(
|
||||||
private final float startX;
|
ByteBufCodecs.VECTOR3F, PacketParticleStream::start,
|
||||||
private final float startY;
|
ByteBufCodecs.VECTOR3F, PacketParticleStream::end,
|
||||||
private final float startZ;
|
ByteBufCodecs.FLOAT, PacketParticleStream::speed,
|
||||||
|
ByteBufCodecs.INT, PacketParticleStream::color,
|
||||||
private final float endX;
|
ByteBufCodecs.FLOAT, PacketParticleStream::scale,
|
||||||
private final float endY;
|
PacketParticleStream::new);
|
||||||
private final float endZ;
|
|
||||||
|
|
||||||
private final float speed;
|
|
||||||
private final int color;
|
|
||||||
private final float scale;
|
|
||||||
|
|
||||||
public PacketParticleStream(float startX, float startY, float startZ, float endX, float endY, float endZ, float speed, int color, float scale) {
|
public PacketParticleStream(float startX, float startY, float startZ, float endX, float endY, float endZ, float speed, int color, float scale) {
|
||||||
this.startX = startX;
|
this(new Vector3f(startX, startY, startZ), new Vector3f(endX, endY, endZ), speed, color, scale);
|
||||||
this.startY = startY;
|
|
||||||
this.startZ = startZ;
|
|
||||||
this.endX = endX;
|
|
||||||
this.endY = endY;
|
|
||||||
this.endZ = endZ;
|
|
||||||
this.speed = speed;
|
|
||||||
this.color = color;
|
|
||||||
this.scale = scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketParticleStream(FriendlyByteBuf buf) {
|
|
||||||
this.startX = buf.readFloat();
|
|
||||||
this.startY = buf.readFloat();
|
|
||||||
this.startZ = buf.readFloat();
|
|
||||||
this.endX = buf.readFloat();
|
|
||||||
this.endY = buf.readFloat();
|
|
||||||
this.endZ = buf.readFloat();
|
|
||||||
this.speed = buf.readFloat();
|
|
||||||
this.color = buf.readInt();
|
|
||||||
this.scale = buf.readFloat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(FriendlyByteBuf buf) {
|
public Type<? extends CustomPacketPayload> type() {
|
||||||
buf.writeFloat(this.startX);
|
return PacketParticleStream.TYPE;
|
||||||
buf.writeFloat(this.startY);
|
|
||||||
buf.writeFloat(this.startZ);
|
|
||||||
buf.writeFloat(this.endX);
|
|
||||||
buf.writeFloat(this.endY);
|
|
||||||
buf.writeFloat(this.endZ);
|
|
||||||
buf.writeFloat(this.speed);
|
|
||||||
buf.writeInt(this.color);
|
|
||||||
buf.writeFloat(this.scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void onMessage(PacketParticleStream message, IPayloadContext ctx) {
|
||||||
public ResourceLocation id() {
|
NaturesAuraAPI.instance().spawnParticleStream(
|
||||||
return PacketParticleStream.ID;
|
message.start.x, message.start.y, message.start.z,
|
||||||
}
|
message.end.x, message.end.y, message.end.z,
|
||||||
|
message.speed, message.color, message.scale);
|
||||||
public static void onMessage(PacketParticleStream message, PlayPayloadContext ctx) {
|
|
||||||
ctx.workHandler().execute(() -> NaturesAuraAPI.instance().spawnParticleStream(
|
|
||||||
message.startX, message.startY, message.startZ,
|
|
||||||
message.endX, message.endY, message.endZ,
|
|
||||||
message.speed, message.color, message.scale));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,66 +11,43 @@ import net.minecraft.client.renderer.BiomeColors;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ItemParticleOption;
|
import net.minecraft.core.particles.ItemParticleOption;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class PacketParticles implements CustomPacketPayload {
|
public record PacketParticles(float posX, float posY, float posZ, int particleType, List<Integer> data) implements CustomPacketPayload {
|
||||||
|
|
||||||
public static final ResourceLocation ID = new ResourceLocation(NaturesAura.MOD_ID, "particles");
|
public static final CustomPacketPayload.Type<PacketParticles> TYPE = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "particles"));
|
||||||
|
public static final StreamCodec<RegistryFriendlyByteBuf, PacketParticles> CODEC = StreamCodec.composite(
|
||||||
|
ByteBufCodecs.FLOAT, PacketParticles::posX,
|
||||||
|
ByteBufCodecs.FLOAT, PacketParticles::posY,
|
||||||
|
ByteBufCodecs.FLOAT, PacketParticles::posZ,
|
||||||
|
ByteBufCodecs.INT, PacketParticles::particleType,
|
||||||
|
ByteBufCodecs.collection(ArrayList::new, ByteBufCodecs.INT), PacketParticles::data,
|
||||||
|
PacketParticles::new);
|
||||||
|
|
||||||
private final float posX;
|
public PacketParticles(float posX, float posY, float posZ, Type particleType, int... data) {
|
||||||
private final float posY;
|
this(posX, posY, posZ, particleType.ordinal(), Arrays.stream(data).boxed().toList());
|
||||||
private final float posZ;
|
|
||||||
private final Type type;
|
|
||||||
private final int[] data;
|
|
||||||
|
|
||||||
public PacketParticles(float posX, float posY, float posZ, Type type, int... data) {
|
|
||||||
this.posX = posX;
|
|
||||||
this.posY = posY;
|
|
||||||
this.posZ = posZ;
|
|
||||||
this.type = type;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketParticles(FriendlyByteBuf buf) {
|
|
||||||
this.posX = buf.readFloat();
|
|
||||||
this.posY = buf.readFloat();
|
|
||||||
this.posZ = buf.readFloat();
|
|
||||||
this.type = Type.values()[buf.readByte()];
|
|
||||||
|
|
||||||
this.data = new int[buf.readByte()];
|
|
||||||
for (var i = 0; i < this.data.length; i++)
|
|
||||||
this.data[i] = buf.readInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(FriendlyByteBuf buf) {
|
public CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
|
||||||
buf.writeFloat(this.posX);
|
return PacketParticles.TYPE;
|
||||||
buf.writeFloat(this.posY);
|
|
||||||
buf.writeFloat(this.posZ);
|
|
||||||
buf.writeByte(this.type.ordinal());
|
|
||||||
|
|
||||||
buf.writeByte(this.data.length);
|
|
||||||
for (var i : this.data)
|
|
||||||
buf.writeInt(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void onMessage(PacketParticles message, IPayloadContext ctx) {
|
||||||
public ResourceLocation id() {
|
var level = Minecraft.getInstance().level;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onMessage(PacketParticles message, PlayPayloadContext ctx) {
|
|
||||||
ctx.workHandler().execute(() -> {
|
|
||||||
var level = ctx.level().orElseThrow();
|
|
||||||
if (level != null)
|
if (level != null)
|
||||||
message.type.action.accept(message, level);
|
Type.values()[message.particleType].action.accept(message, level);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
|
@ -115,7 +92,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
ALTAR_CONVERSION((message, level) -> {
|
ALTAR_CONVERSION((message, level) -> {
|
||||||
var color = message.data[0];
|
var color = message.data.getFirst();
|
||||||
for (var i = level.random.nextInt(5) + 2; i >= 0; i--) {
|
for (var i = level.random.nextInt(5) + 2; i >= 0; i--) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + 0.25F + level.random.nextFloat() * 0.5F,
|
message.posX + 0.25F + level.random.nextFloat() * 0.5F,
|
||||||
|
@ -126,8 +103,8 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
POTION_GEN((message, level) -> {
|
POTION_GEN((message, level) -> {
|
||||||
var color = message.data[0];
|
var color = message.data.getFirst();
|
||||||
var releaseAura = message.data[1] > 0;
|
var releaseAura = message.data.get(1) > 0;
|
||||||
for (var i = level.random.nextInt(5) + 5; i >= 0; i--) {
|
for (var i = level.random.nextInt(5) + 5; i >= 0; i--) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + level.random.nextFloat(),
|
message.posX + level.random.nextFloat(),
|
||||||
|
@ -160,7 +137,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0x5ccc30, 1F + level.random.nextFloat() * 2F, 50, 0F, false, true);
|
0x5ccc30, 1F + level.random.nextFloat() * 2F, 50, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
FLOWER_GEN_CONSUME((message, level) -> {
|
FLOWER_GEN_CONSUME((message, level) -> {
|
||||||
var color = message.data[0];
|
var color = message.data.getFirst();
|
||||||
for (var i = level.random.nextInt(10) + 10; i >= 0; i--)
|
for (var i = level.random.nextInt(10) + 10; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + 0.25F + level.random.nextFloat() * 0.5F,
|
message.posX + 0.25F + level.random.nextFloat() * 0.5F,
|
||||||
|
@ -214,10 +191,10 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
OAK_GENERATOR((message, level) -> {
|
OAK_GENERATOR((message, level) -> {
|
||||||
var sapX = message.data[0];
|
var sapX = message.data.getFirst();
|
||||||
var sapY = message.data[1];
|
var sapY = message.data.get(1);
|
||||||
var sapZ = message.data[2];
|
var sapZ = message.data.get(2);
|
||||||
var releaseAura = message.data[3] > 0;
|
var releaseAura = message.data.get(3) > 0;
|
||||||
for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
|
for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnParticleStream(
|
NaturesAuraAPI.instance().spawnParticleStream(
|
||||||
sapX + 0.5F + (float) level.random.nextGaussian() * 3F,
|
sapX + 0.5F + (float) level.random.nextGaussian() * 3F,
|
||||||
|
@ -239,9 +216,9 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 60, 0F, false, true);
|
0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 60, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
OFFERING_TABLE((message, level) -> {
|
OFFERING_TABLE((message, level) -> {
|
||||||
var genX = message.data[0];
|
var genX = message.data.getFirst();
|
||||||
var genY = message.data[1];
|
var genY = message.data.get(1);
|
||||||
var genZ = message.data[2];
|
var genZ = message.data.get(2);
|
||||||
for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
|
for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX, message.posY + 0.5F, message.posZ,
|
message.posX, message.posY + 0.5F, message.posZ,
|
||||||
|
@ -286,11 +263,11 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0xd13308, 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
|
0xd13308, 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
ANIMAL_GEN_CONSUME((message, level) -> {
|
ANIMAL_GEN_CONSUME((message, level) -> {
|
||||||
var child = message.data[0] > 0;
|
var child = message.data.getFirst() > 0;
|
||||||
var height = message.data[1] / 10F;
|
var height = message.data.get(1) / 10F;
|
||||||
var genX = message.data[2];
|
var genX = message.data.get(2);
|
||||||
var genY = message.data[3];
|
var genY = message.data.get(3);
|
||||||
var genZ = message.data[4];
|
var genZ = message.data.get(4);
|
||||||
for (var i = child ? level.random.nextInt(10) + 10 : level.random.nextInt(20) + 20; i >= 0; i--)
|
for (var i = child ? level.random.nextInt(10) + 10 : level.random.nextInt(20) + 20; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + level.random.nextGaussian() * 0.25F,
|
message.posX + level.random.nextGaussian() * 0.25F,
|
||||||
|
@ -306,7 +283,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0.15F, 0x41c4f4, child ? 1.5F : 3F);
|
0.15F, 0x41c4f4, child ? 1.5F : 3F);
|
||||||
}),
|
}),
|
||||||
END_FLOWER_DECAY((message, level) -> {
|
END_FLOWER_DECAY((message, level) -> {
|
||||||
var color = message.data[0];
|
var color = message.data.getFirst();
|
||||||
for (var i = level.random.nextInt(10) + 20; i >= 0; i--)
|
for (var i = level.random.nextInt(10) + 20; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + level.random.nextFloat(),
|
message.posX + level.random.nextFloat(),
|
||||||
|
@ -343,7 +320,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
END_FLOWER_CONSUME((message, level) -> {
|
END_FLOWER_CONSUME((message, level) -> {
|
||||||
var color = message.data[0];
|
var color = message.data.getFirst();
|
||||||
for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
|
for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX, message.posY + 0.5F, message.posZ,
|
message.posX, message.posY + 0.5F, message.posZ,
|
||||||
|
@ -353,9 +330,9 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
color, 1.5F, 40, 0F, false, true);
|
color, 1.5F, 40, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
MOVER_CART((message, level) -> {
|
MOVER_CART((message, level) -> {
|
||||||
var motionX = message.data[0] / 100F;
|
var motionX = message.data.getFirst() / 100F;
|
||||||
var motionY = message.data[1] / 100F;
|
var motionY = message.data.get(1) / 100F;
|
||||||
var motionZ = message.data[2] / 100F;
|
var motionZ = message.data.get(2) / 100F;
|
||||||
for (var i = level.random.nextInt(60) + 30; i >= 0; i--)
|
for (var i = level.random.nextInt(60) + 30; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + level.random.nextGaussian() * 10F,
|
message.posX + level.random.nextGaussian() * 10F,
|
||||||
|
@ -388,9 +365,9 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 40, 0F, true, true);
|
0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 40, 0F, true, true);
|
||||||
}),
|
}),
|
||||||
FIREWORK_GEN((message, level) -> {
|
FIREWORK_GEN((message, level) -> {
|
||||||
var goalX = message.data[0];
|
var goalX = message.data.getFirst();
|
||||||
var goalY = message.data[1];
|
var goalY = message.data.get(1);
|
||||||
var goalZ = message.data[2];
|
var goalZ = message.data.get(2);
|
||||||
NaturesAuraAPI.instance().setParticleSpawnRange(64);
|
NaturesAuraAPI.instance().setParticleSpawnRange(64);
|
||||||
for (var i = level.random.nextInt(30) + 30; i >= 0; i--)
|
for (var i = level.random.nextInt(30) + 30; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnParticleStream(
|
NaturesAuraAPI.instance().spawnParticleStream(
|
||||||
|
@ -400,13 +377,13 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
goalX + 0.25F + level.random.nextFloat() * 0.5F,
|
goalX + 0.25F + level.random.nextFloat() * 0.5F,
|
||||||
goalY + 0.25F + level.random.nextFloat() * 0.5F,
|
goalY + 0.25F + level.random.nextFloat() * 0.5F,
|
||||||
goalZ + 0.25F + level.random.nextFloat() * 0.5F,
|
goalZ + 0.25F + level.random.nextFloat() * 0.5F,
|
||||||
0.65F, message.data[3 + level.random.nextInt(message.data.length - 3)], 1F);
|
0.65F, message.data.get(3 + level.random.nextInt(message.data.size() - 3)), 1F);
|
||||||
NaturesAuraAPI.instance().setParticleSpawnRange(32);
|
NaturesAuraAPI.instance().setParticleSpawnRange(32);
|
||||||
}),
|
}),
|
||||||
DIMENSION_RAIL((message, level) -> {
|
DIMENSION_RAIL((message, level) -> {
|
||||||
var width = message.data[0] / 100F;
|
var width = message.data.getFirst() / 100F;
|
||||||
var height = message.data[1] / 100F;
|
var height = message.data.get(1) / 100F;
|
||||||
var depth = message.data[2] / 100F;
|
var depth = message.data.get(2) / 100F;
|
||||||
for (var i = level.random.nextInt(100) + 50; i >= 0; i--)
|
for (var i = level.random.nextInt(100) + 50; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + level.random.nextFloat() * width,
|
message.posX + level.random.nextFloat() * width,
|
||||||
|
@ -415,9 +392,9 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0F, 0F, 0F, 0xd60cff, 1F + level.random.nextFloat(), 60, 0F, false, true);
|
0F, 0F, 0F, 0xd60cff, 1F + level.random.nextFloat(), 60, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
PROJECTILE_GEN((message, level) -> {
|
PROJECTILE_GEN((message, level) -> {
|
||||||
var x = message.data[0];
|
var x = message.data.getFirst();
|
||||||
var y = message.data[1];
|
var y = message.data.get(1);
|
||||||
var z = message.data[2];
|
var z = message.data.get(2);
|
||||||
for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
|
for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
x + 0.25F + level.random.nextFloat() * 0.5F,
|
x + 0.25F + level.random.nextFloat() * 0.5F,
|
||||||
|
@ -435,7 +412,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
level.random.nextGaussian() * 0.03F);
|
level.random.nextGaussian() * 0.03F);
|
||||||
}),
|
}),
|
||||||
BLAST_FURNACE_BOOSTER((message, level) -> {
|
BLAST_FURNACE_BOOSTER((message, level) -> {
|
||||||
var worked = message.data[0] > 0;
|
var worked = message.data.getFirst() > 0;
|
||||||
for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
|
for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
|
||||||
level.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE,
|
level.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE,
|
||||||
message.posX + 5 / 16F + level.random.nextInt(6) / 16F,
|
message.posX + 5 / 16F + level.random.nextInt(6) / 16F,
|
||||||
|
@ -480,9 +457,9 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
CHORUS_GENERATOR((message, level) -> {
|
CHORUS_GENERATOR((message, level) -> {
|
||||||
var chorusX = message.data[0];
|
var chorusX = message.data.getFirst();
|
||||||
var chorusY = message.data[1];
|
var chorusY = message.data.get(1);
|
||||||
var chorusZ = message.data[2];
|
var chorusZ = message.data.get(2);
|
||||||
for (var i = level.random.nextInt(5) + 3; i >= 0; i--)
|
for (var i = level.random.nextInt(5) + 3; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
chorusX + level.random.nextFloat(), chorusY + level.random.nextFloat(), chorusZ + level.random.nextFloat(),
|
chorusX + level.random.nextFloat(), chorusY + level.random.nextFloat(), chorusZ + level.random.nextFloat(),
|
||||||
|
@ -499,7 +476,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
IAuraType.forLevel(level).getColor(), 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
|
IAuraType.forLevel(level).getColor(), 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
TIMER_RESET((message, level) -> {
|
TIMER_RESET((message, level) -> {
|
||||||
var color = message.data[0];
|
var color = message.data.getFirst();
|
||||||
for (var i = level.random.nextInt(10) + 15; i >= 0; i--)
|
for (var i = level.random.nextInt(10) + 15; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + 5 / 16F + level.random.nextFloat() * 6 / 16F,
|
message.posX + 5 / 16F + level.random.nextFloat() * 6 / 16F,
|
||||||
|
@ -508,7 +485,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
0, 0, 0, color, 2, 40 + level.random.nextInt(20), 0, false, true);
|
0, 0, 0, color, 2, 40 + level.random.nextInt(20), 0, false, true);
|
||||||
}),
|
}),
|
||||||
STRUCTURE_FINDER((message, level) -> {
|
STRUCTURE_FINDER((message, level) -> {
|
||||||
var entity = (EntityStructureFinder) level.getEntity(message.data[0]);
|
var entity = (EntityStructureFinder) level.getEntity(message.data.getFirst());
|
||||||
var renderer = Minecraft.getInstance().levelRenderer;
|
var renderer = Minecraft.getInstance().levelRenderer;
|
||||||
|
|
||||||
var d0 = message.posX + 0.5D;
|
var d0 = message.posX + 0.5D;
|
||||||
|
@ -532,13 +509,13 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
level.random.nextGaussian() * 0.01F,
|
level.random.nextGaussian() * 0.01F,
|
||||||
level.random.nextFloat() * 0.04F + 0.02F,
|
level.random.nextFloat() * 0.04F + 0.02F,
|
||||||
level.random.nextGaussian() * 0.01F,
|
level.random.nextGaussian() * 0.01F,
|
||||||
message.data[0], 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
|
message.data.getFirst(), 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
|
||||||
}),
|
}),
|
||||||
SLIME_SPLIT_GEN_START((message, level) -> {
|
SLIME_SPLIT_GEN_START((message, level) -> {
|
||||||
var x = message.data[0];
|
var x = message.data.getFirst();
|
||||||
var y = message.data[1];
|
var y = message.data.get(1);
|
||||||
var z = message.data[2];
|
var z = message.data.get(2);
|
||||||
var color = message.data[3];
|
var color = message.data.get(3);
|
||||||
for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
|
for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
message.posX + (float) level.random.nextGaussian() * 0.5F,
|
message.posX + (float) level.random.nextGaussian() * 0.5F,
|
||||||
|
@ -564,7 +541,7 @@ public class PacketParticles implements CustomPacketPayload {
|
||||||
level.random.nextGaussian() * 0.002F,
|
level.random.nextGaussian() * 0.002F,
|
||||||
level.random.nextFloat() * 0.001F + 0.002F,
|
level.random.nextFloat() * 0.001F + 0.002F,
|
||||||
level.random.nextGaussian() * 0.002F,
|
level.random.nextGaussian() * 0.002F,
|
||||||
message.data[0], level.random.nextFloat() * 2 + 1, level.random.nextInt(50) + 50, 0, false, true);
|
message.data.getFirst(), level.random.nextFloat() * 2 + 1, level.random.nextInt(50) + 50, 0, false, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
public final BiConsumer<PacketParticles, Level> action;
|
public final BiConsumer<PacketParticles, Level> action;
|
||||||
|
|
Loading…
Reference in a new issue