mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Compare commits
12 commits
f32f7187cc
...
ecada0d3d9
Author | SHA1 | Date | |
---|---|---|---|
|
ecada0d3d9 | ||
|
3330a3b320 | ||
|
d088aba777 | ||
|
9abb4868d6 | ||
|
bae1ef5e91 | ||
|
e1e92d577a | ||
|
4dd12e74fd | ||
|
1e965230e5 | ||
|
ae60e77a2c | ||
|
0ac1e81d0e | ||
|
8fd9afe8d7 | ||
|
844efe4260 |
43 changed files with 242 additions and 201 deletions
|
@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G
|
|||
org.gradle.daemon=false
|
||||
# Actually Additions
|
||||
|
||||
mod_version=1.3.2
|
||||
mod_version=1.3.4
|
||||
|
||||
# Forge
|
||||
game_version=1.21.1
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
*/
|
||||
/*
|
||||
@API(owner = ActuallyAdditionsAPI.MOD_ID, apiVersion = ActuallyAdditionsAPI.API_VERSION, provides = ActuallyAdditionsAPI.API_ID)
|
||||
package de.ellpeck.actuallyadditions.api;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
*/
|
||||
*/
|
||||
package de.ellpeck.actuallyadditions.api;
|
|
@ -35,7 +35,6 @@ import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler
|
|||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.particle.ActuallyParticles;
|
||||
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ResourceReloader;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -129,7 +128,7 @@ public class ActuallyAdditions {
|
|||
|
||||
commonCapsLoaded = false; // Loader.isModLoaded("commoncapabilities");
|
||||
|
||||
new UpdateChecker();
|
||||
// new UpdateChecker();
|
||||
}
|
||||
|
||||
private void onConfigReload(ModConfigEvent event) {
|
||||
|
|
|
@ -163,8 +163,8 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
|||
|
||||
if (this.lastSysTime + 3000 < sysTime) {
|
||||
this.lastSysTime = sysTime;
|
||||
if (Minecraft.getInstance().level != null) {
|
||||
RandomSource random = Minecraft.getInstance().level.random;
|
||||
if (context.level() != null) {
|
||||
RandomSource random = context.level().random;
|
||||
this.toPick1 = random.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
|
||||
this.toPick2 = random.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public class RenderBatteryBox implements BlockEntityRenderer<TileEntityBatteryBo
|
|||
try {
|
||||
AssetUtil.renderItemInWorld(stack, combinedLight, combinedOverlay, matrices, buffer);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is " + BuiltInRegistries.ITEM.getKey(stack.getItem()) + "!", e);
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is {}!", BuiltInRegistries.ITEM.getKey(stack.getItem()), e);
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class RenderDisplayStand implements BlockEntityRenderer<TileEntityDisplay
|
|||
try {
|
||||
AssetUtil.renderItemInWorld(stack, combinedLightIn, combinedOverlayIn, matrices, buffer);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is " + BuiltInRegistries.ITEM.getKey(stack.getItem()) + "!", e);
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is {}!", BuiltInRegistries.ITEM.getKey(stack.getItem()), e);
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class RenderEmpowerer implements BlockEntityRenderer<TileEntityEmpowerer>
|
|||
try {
|
||||
AssetUtil.renderItemInWorld(stack, combinedLight, combinedOverlay, matrices, buffer);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is " + BuiltInRegistries.ITEM.getKey(stack.getItem()) + "!", e);
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is {}!", BuiltInRegistries.ITEM.getKey(stack.getItem()), e);
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class RecipeKeepDataShaped extends ShapedRecipe {
|
|||
RecipeSerializer.SHAPED_RECIPE.streamCodec().encode(buffer, recipe);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
ActuallyAdditions.LOGGER.info("Error writing "+ NAME +" Recipe to packet: ", exception);
|
||||
ActuallyAdditions.LOGGER.info("Error writing {} Recipe to packet: ", NAME, exception);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class RecipeKeepDataShapeless extends ShapelessRecipe {
|
|||
RecipeSerializer.SHAPELESS_RECIPE.streamCodec().encode(pBuffer, pRecipe);
|
||||
}
|
||||
catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.info("Failed to serialize " + NAME + " Recipe to packet: " + e.getMessage());
|
||||
ActuallyAdditions.LOGGER.info("Failed to serialize {} Recipe to packet: {}", NAME, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.event;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import de.ellpeck.actuallyadditions.api.misc.IGoggles;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
||||
|
@ -23,6 +24,7 @@ import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay;
|
|||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
|
@ -30,12 +32,14 @@ import net.minecraft.client.gui.GuiGraphics;
|
|||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -47,6 +51,7 @@ import net.neoforged.neoforge.client.gui.VanillaGuiLayers;
|
|||
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class ClientEvents {
|
||||
|
@ -64,6 +69,52 @@ public class ClientEvents {
|
|||
if (mc.level == null) {
|
||||
WorldData.clear();
|
||||
}
|
||||
|
||||
if (mc.player != null) {
|
||||
renderEngineerEffect(mc.player);
|
||||
}
|
||||
}
|
||||
|
||||
private final Set<Entity> cachedGlowingEntities = new ConcurrentSet<>();
|
||||
|
||||
/**
|
||||
* Renders a special visual effect for entities around the player if the player is wearing goggles that allow them to see spectral mobs.
|
||||
*
|
||||
* @param player The player wearing the goggles.
|
||||
*/
|
||||
private void renderEngineerEffect(Player player) {
|
||||
ItemStack face = player.getInventory().armor.get(3);
|
||||
if (player != null && !face.isEmpty() && face.getItem() instanceof IGoggles goggles && goggles.displaySpectralMobs()) {
|
||||
double range = 8;
|
||||
AABB aabb = new AABB(player.getX() - range, player.getY() - range, player.getZ() - range, player.getX() + range, player.getY() + range, player.getZ() + range);
|
||||
List<Entity> entities = player.level().getEntitiesOfClass(Entity.class, aabb);
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
this.cachedGlowingEntities.addAll(entities);
|
||||
}
|
||||
|
||||
if (!this.cachedGlowingEntities.isEmpty()) {
|
||||
for (Entity entity : this.cachedGlowingEntities) {
|
||||
if (!entity.isAlive() || entity.distanceToSqr(player.getX(), player.getY(), player.getZ()) > range * range) {
|
||||
entity.setGlowingTag(false);
|
||||
|
||||
this.cachedGlowingEntities.remove(entity);
|
||||
} else {
|
||||
entity.setGlowingTag(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.cachedGlowingEntities.isEmpty()) {
|
||||
for (Entity entity : this.cachedGlowingEntities) {
|
||||
if (entity.isAlive()) {
|
||||
entity.setGlowingTag(false);
|
||||
}
|
||||
}
|
||||
this.cachedGlowingEntities.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -21,7 +21,7 @@ import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
|||
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemTag;
|
||||
import de.ellpeck.actuallyadditions.mod.items.Sack;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
||||
import de.ellpeck.actuallyadditions.mod.sack.SackManager;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||
|
@ -184,8 +184,8 @@ public class CommonEvents {
|
|||
@SubscribeEvent
|
||||
public void onLogInEvent(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.getEntity().level().isClientSide && event.getEntity() instanceof ServerPlayer player) {
|
||||
PacketHandlerHelper.syncPlayerData(player, true);
|
||||
ActuallyAdditions.LOGGER.info("Sending Player Data to player " + player.getName() + " with UUID " + player.getUUID() + ".");
|
||||
PacketHelperServer.syncPlayerData(player, true);
|
||||
ActuallyAdditions.LOGGER.info("Sending Player Data to player {} with UUID {}.", player.getName(), player.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Deprecated(forRemoval = true) //Unused because vanilla's Button class can render small just fine and even allows text scrolling
|
||||
public class Buttons {
|
||||
|
||||
@Deprecated(forRemoval = true) //Vanilla's Button class can render small just fine and even allows text scrolling
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.CrusherContainer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCrusher;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -62,7 +62,7 @@ public class CrusherScreen extends AAScreen<CrusherContainer> {
|
|||
|
||||
protected void actionPerformed(int id) {
|
||||
if (this.isDouble && id == 0) {
|
||||
PacketHandlerHelper.sendButtonPacket(this.tileGrinder, id);
|
||||
PacketHelperClient.sendButtonPacket(this.tileGrinder, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -46,7 +46,7 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
|
|||
super.init();
|
||||
|
||||
this.addRenderableWidget(new Button.Builder(Component.translatable("info.actuallyadditions.gui.ok"),
|
||||
(b) -> PacketHandlerHelper.sendButtonPacket(this.machine, 0))
|
||||
(b) -> PacketHelperClient.sendButtonPacket(this.machine, 0))
|
||||
.bounds(this.leftPos + 60, this.topPos + 11, 58, 20).build());
|
||||
|
||||
this.energy = new EnergyDisplay(this.leftPos + 16, this.topPos + 5, this.machine.storage);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFireworkBox;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
@ -45,20 +45,20 @@ public class GuiFireworkBox extends AbstractContainerScreen<ContainerFireworkBox
|
|||
|
||||
DecimalFormat intFormatter = new DecimalFormat("0");
|
||||
int left = this.getGuiLeft() + 2;
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 2, Component.literal("Value Play"), 0F, 5F, this.tile.intValuePlay, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 0)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 23, Component.literal("Average Charge Amount"), 1F, 4F, this.tile.chargeAmount, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 1)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 44, Component.literal("Average Flight Time"), 1F, 3F, this.tile.flightTime, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 2)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 65, Component.literal("Effect Chance"), 0F, 1F, this.tile.trailOrFlickerChance, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 3)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 86, Component.literal("Flicker/Trail Ratio"), 0F, 1F, this.tile.flickerChance, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 4)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 107, Component.literal("Color Amount"), 1, 6, this.tile.colorAmount, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 5)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 2, Component.literal("Value Play"), 0F, 5F, this.tile.intValuePlay, intFormatter, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 0)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 23, Component.literal("Average Charge Amount"), 1F, 4F, this.tile.chargeAmount, intFormatter, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 1)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 44, Component.literal("Average Flight Time"), 1F, 3F, this.tile.flightTime, intFormatter, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 2)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 65, Component.literal("Effect Chance"), 0F, 1F, this.tile.trailOrFlickerChance, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 3)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 86, Component.literal("Flicker/Trail Ratio"), 0F, 1F, this.tile.flickerChance, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 4)));
|
||||
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 107, Component.literal("Color Amount"), 1, 6, this.tile.colorAmount, intFormatter, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 5)));
|
||||
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 2, Component.literal("Small Ball"), 0F, 1F, this.tile.typeChance0, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 6)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 23, Component.literal("Large Ball"), 0F, 1F, this.tile.typeChance1, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 7)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 44, Component.literal("Star Shape"), 0F, 1F, this.tile.typeChance2, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 8)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 65, Component.literal("Creeper Shape"), 0F, 1F, this.tile.typeChance3, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 9)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 86, Component.literal("Burst"), 0F, 1F, this.tile.typeChance4, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 10)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 2, Component.literal("Small Ball"), 0F, 1F, this.tile.typeChance0, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 6)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 23, Component.literal("Large Ball"), 0F, 1F, this.tile.typeChance1, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 7)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 44, Component.literal("Star Shape"), 0F, 1F, this.tile.typeChance2, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 8)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 65, Component.literal("Creeper Shape"), 0F, 1F, this.tile.typeChance3, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 9)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 86, Component.literal("Burst"), 0F, 1F, this.tile.typeChance4, null, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 10)));
|
||||
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 107, Component.literal("Area of Effect"), 0, 4, this.tile.areaOfEffect, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 11)));
|
||||
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 107, Component.literal("Area of Effect"), 0, 4, this.tile.areaOfEffect, intFormatter, (slider) -> PacketHelperClient.sendNumberPacket(this.tile, slider.getValue(), 11)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPoweredFurnace;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -54,7 +54,7 @@ public class GuiFurnaceDouble extends AAScreen<ContainerFurnaceDouble> {
|
|||
public void init() {
|
||||
super.init();
|
||||
this.energy = new EnergyDisplay(this.leftPos + 27, this.topPos + 5, this.tileFurnace.storage);
|
||||
this.buttonAutoSplit = Button.builder(Component.literal("S"), (button) -> PacketHandlerHelper.sendButtonPacket(this.tileFurnace, 0))
|
||||
this.buttonAutoSplit = Button.builder(Component.literal("S"), (button) -> PacketHelperClient.sendButtonPacket(this.tileFurnace, 0))
|
||||
.bounds(this.getGuiLeft(), this.topPos + 5, 16, 16).build();
|
||||
buttonAutoSplit.setFGColor(this.tileFurnace.isAutoSplit ? ChatFormatting.DARK_GREEN.getColor() : ChatFormatting.RED.getColor());
|
||||
this.addRenderableWidget(this.buttonAutoSplit);
|
||||
|
|
|
@ -12,9 +12,9 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemAdvanced;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -71,14 +71,14 @@ public class GuiLaserRelayItemWhitelist extends AAScreen<ContainerLaserRelayItem
|
|||
this.buttonSmartWhitelistLeft = this.addRenderableWidget(Button.builder(
|
||||
Component.literal("S"),
|
||||
(button) -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.tile, 2);
|
||||
PacketHelperClient.sendButtonPacket(this.tile, 2);
|
||||
}).bounds(this.leftPos + 3, this.topPos + 79, 16, 16)
|
||||
.build());
|
||||
|
||||
this.buttonSmartWhitelistRight = this.addRenderableWidget(Button.builder(
|
||||
Component.literal("S"),
|
||||
(button) -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.tile, 3);
|
||||
PacketHelperClient.sendButtonPacket(this.tile, 3);
|
||||
}).bounds(this.leftPos + 157, this.topPos + 79, 16, 16)
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
@ -40,10 +40,10 @@ public class GuiMiner extends AAScreen<ContainerMiner> {
|
|||
super.init();
|
||||
|
||||
this.addRenderableWidget(Button.builder(Component.literal("Mode"), $ -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.miner, 0);
|
||||
PacketHelperClient.sendButtonPacket(this.miner, 0);
|
||||
}).bounds(this.leftPos + this.imageWidth / 2 - 51, this.topPos + 75, 50, 20).build());
|
||||
this.addRenderableWidget(Button.builder(Component.literal("Reset"), $ -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.miner, 1);
|
||||
PacketHelperClient.sendButtonPacket(this.miner, 1);
|
||||
}).bounds(this.leftPos + this.imageWidth / 2 + 1, this.topPos + 75, 50, 20).build());
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerPhantomPlacer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -45,7 +45,7 @@ public class GuiPhantomPlacer extends AAScreen<ContainerPhantomPlacer> {
|
|||
super.init();
|
||||
|
||||
if (!this.placer.isBreaker) {
|
||||
buttonSide = Button.builder(Component.literal(this.getSide()), (button) -> PacketHandlerHelper.sendButtonPacket(this.placer, 0))
|
||||
buttonSide = Button.builder(Component.literal(this.getSide()), (button) -> PacketHelperClient.sendButtonPacket(this.placer, 0))
|
||||
.bounds(this.leftPos + 63, this.topPos + 75, 50, 20).build();
|
||||
this.addRenderableWidget(buttonSide);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.ContainerSmileyCloud;
|
||||
//import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
//import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
//import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerXPSolidifier;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperClient;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
@ -39,39 +39,39 @@ public class GuiXPSolidifier extends AAScreen<ContainerXPSolidifier> {
|
|||
super.init();
|
||||
|
||||
Button buttonOne = this.addRenderableWidget(Button.builder(Component.literal("1"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 0);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 0);
|
||||
this.solidifier.onButtonPressed(0, minecraft.player);
|
||||
}).bounds(this.leftPos + 62, this.topPos + 44, 16, 16).build());
|
||||
Button buttonFive = this.addRenderableWidget(Button.builder(Component.literal("5"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 1);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 1);
|
||||
this.solidifier.onButtonPressed(1, minecraft.player);
|
||||
}).bounds(this.leftPos + 80, this.topPos + 44, 16, 16).build());
|
||||
Button buttonTen = this.addRenderableWidget(Button.builder(Component.literal("10"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 2);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 2);
|
||||
this.solidifier.onButtonPressed(2, minecraft.player);
|
||||
}).bounds(this.leftPos + 99, this.topPos + 44, 16, 16).build());
|
||||
Button buttonTwenty = this.addRenderableWidget(Button.builder(Component.literal("20"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 3);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 3);
|
||||
this.solidifier.onButtonPressed(3, minecraft.player);
|
||||
}).bounds(this.leftPos + 62, this.topPos + 61, 16, 16).build());
|
||||
Button buttonThirty = this.addRenderableWidget(Button.builder(Component.literal("30"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 4);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 4);
|
||||
this.solidifier.onButtonPressed(4, minecraft.player);
|
||||
}).bounds(this.leftPos + 80, this.topPos + 61, 16, 16).build());
|
||||
Button buttonForty = this.addRenderableWidget(Button.builder(Component.literal("40"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 5);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 5);
|
||||
this.solidifier.onButtonPressed(5, minecraft.player);
|
||||
}).bounds(this.leftPos + 99, this.topPos + 61, 16, 16).build());
|
||||
Button buttonFifty = this.addRenderableWidget(Button.builder(Component.literal("50"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 6);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 6);
|
||||
this.solidifier.onButtonPressed(6, minecraft.player);
|
||||
}).bounds(this.leftPos + 62, this.topPos + 78, 16, 16).build());
|
||||
Button buttonSixtyFour = this.addRenderableWidget(Button.builder(Component.literal("64"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 7);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 7);
|
||||
this.solidifier.onButtonPressed(7, minecraft.player);
|
||||
}).bounds(this.leftPos + 80, this.topPos + 78, 16, 16).build());
|
||||
Button buttonAll = this.addRenderableWidget(Button.builder(Component.literal("All"), btn -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.solidifier, 8);
|
||||
PacketHelperClient.sendButtonPacket(this.solidifier, 8);
|
||||
this.solidifier.onButtonPressed(8, minecraft.player);
|
||||
}).bounds(this.leftPos + 99, this.topPos + 78, 16, 16).build());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ItemTagContainer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.SackContainer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.VoidSackContainer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.mojang.datafixers.util.Pair;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
|
|
|
@ -13,34 +13,16 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.api.misc.IGoggles;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA;
|
||||
import de.ellpeck.actuallyadditions.mod.material.ArmorMaterials;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles {
|
||||
|
||||
private final Set<Entity> cachedGlowingEntities = new ConcurrentSet<>();
|
||||
|
||||
private final boolean displayMobs;
|
||||
|
||||
public ItemEngineerGoggles(boolean displayMobs) {
|
||||
super(ArmorMaterials.GOGGLES, Type.HELMET, ActuallyItems.defaultProps().setNoRepair().durability(0));
|
||||
this.displayMobs = displayMobs;
|
||||
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isWearing(Player player) {
|
||||
|
@ -48,46 +30,6 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles {
|
|||
return !face.isEmpty() && face.getItem() instanceof IGoggles;
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(ClientTickEvent.Post event) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player != null && isWearing(player)) {
|
||||
ItemStack face = player.getInventory().armor.get(3);
|
||||
if (((IGoggles) face.getItem()).displaySpectralMobs()) {
|
||||
double range = 8;
|
||||
AABB aabb = new AABB(player.getX() - range, player.getY() - range, player.getZ() - range, player.getX() + range, player.getY() + range, player.getZ() + range);
|
||||
List<Entity> entities = player.level().getEntitiesOfClass(Entity.class, aabb);
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
this.cachedGlowingEntities.addAll(entities);
|
||||
}
|
||||
|
||||
if (!this.cachedGlowingEntities.isEmpty()) {
|
||||
for (Entity entity : this.cachedGlowingEntities) {
|
||||
if (!entity.isAlive() || entity.distanceToSqr(player.getX(), player.getY(), player.getZ()) > range * range) {
|
||||
entity.setGlowingTag(false);
|
||||
|
||||
this.cachedGlowingEntities.remove(entity);
|
||||
} else {
|
||||
entity.setGlowingTag(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.cachedGlowingEntities.isEmpty()) {
|
||||
for (Entity entity : this.cachedGlowingEntities) {
|
||||
if (entity.isAlive()) {
|
||||
entity.setGlowingTag(false);
|
||||
}
|
||||
}
|
||||
this.cachedGlowingEntities.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displaySpectralMobs() {
|
||||
return this.displayMobs;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -40,10 +39,10 @@ public class ItemTeleportStaff extends ItemEnergy {
|
|||
Vec3 pos = Vec3.atBottomCenterOf(BlockPos.containing(location.x, location.y, location.z));
|
||||
int baseUse = 200;
|
||||
int use = baseUse + (int) (baseUse * Math.sqrt(player.blockPosition().distManhattan(BlockPos.containing(pos.x, pos.y, pos.z))));
|
||||
ActuallyAdditions.LOGGER.info("Use: " + use + " Energy: " + this.getEnergyStored(stack));
|
||||
ActuallyAdditions.LOGGER.info("Distance: " + Math.sqrt(player.blockPosition().distSqr(BlockPos.containing(pos.x, pos.y, pos.z))));
|
||||
ActuallyAdditions.LOGGER.info("Player: " + player.blockPosition());
|
||||
ActuallyAdditions.LOGGER.info("Pos: " + pos);
|
||||
// ActuallyAdditions.LOGGER.info("Use: " + use + " Energy: " + this.getEnergyStored(stack));
|
||||
// ActuallyAdditions.LOGGER.info("Distance: " + Math.sqrt(player.blockPosition().distSqr(BlockPos.containing(pos.x, pos.y, pos.z))));
|
||||
// ActuallyAdditions.LOGGER.info("Player: " + player.blockPosition());
|
||||
// ActuallyAdditions.LOGGER.info("Pos: " + pos);
|
||||
if (this.getEnergyStored(stack) >= use) {
|
||||
((ServerPlayer) player).connection.teleport(pos.x, pos.y + 1F, pos.z, player.getYRot(), player.getXRot());
|
||||
player.removeVehicle();
|
||||
|
|
|
@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -178,7 +178,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
|||
}
|
||||
|
||||
if (shouldSend) {
|
||||
PacketHandlerHelper.syncPlayerData(player, false);
|
||||
PacketHelperServer.syncPlayerData(player, false);
|
||||
data.shouldDisableBatWings = false; //was set only temporarily to send it
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer;
|
|||
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
|
|
@ -16,19 +16,17 @@ import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
|||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.particle.ParticleLaserItem;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketServerToClient;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
|
@ -43,41 +41,26 @@ public final class PacketHandler {
|
|||
public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<>();
|
||||
public static final IDataHandler LASER_HANDLER = new IDataHandler() {
|
||||
@Override
|
||||
|
||||
public void handleData(CompoundTag compound, IPayloadContext context) {
|
||||
AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInt("Color"), compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha"));
|
||||
if(context.flow() == PacketFlow.CLIENTBOUND) {
|
||||
PacketHelperClient.handleLaser(compound, context);
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() {
|
||||
@Override
|
||||
|
||||
public void handleData(CompoundTag compound, IPayloadContext context) {
|
||||
Level world = Minecraft.getInstance().level;
|
||||
if (world != null) {
|
||||
BlockEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z")));
|
||||
if (tile instanceof TileEntityBase) {
|
||||
((TileEntityBase) tile).readSyncableNBT(compound.getCompound("Data"), world.registryAccess(), TileEntityBase.NBTType.SYNC);
|
||||
}
|
||||
if(context.flow() == PacketFlow.CLIENTBOUND) {
|
||||
PacketHelperClient.handleTileUpdate(compound, context);
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final IDataHandler LASER_PARTICLE_HANDLER = new IDataHandler() {
|
||||
@Override
|
||||
|
||||
public void handleData(CompoundTag compound, IPayloadContext context) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemStack stack = ItemStack.parseOptional(context.player().registryAccess(), compound);
|
||||
|
||||
double inX = compound.getDouble("InX") + 0.5;
|
||||
double inY = compound.getDouble("InY") + 0.78;
|
||||
double inZ = compound.getDouble("InZ") + 0.5;
|
||||
|
||||
double outX = compound.getDouble("OutX") + 0.5;
|
||||
double outY = compound.getDouble("OutY") + 0.525;
|
||||
double outZ = compound.getDouble("OutZ") + 0.5;
|
||||
|
||||
mc.level.addParticle(ParticleLaserItem.Factory.createData(stack, inX, inY, inZ),
|
||||
outX, outY, outZ, 0, 0.025, 0);
|
||||
if(context.flow() == PacketFlow.CLIENTBOUND) {
|
||||
PacketHelperClient.handleLaserParticle(compound, context);
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> {
|
||||
|
@ -131,19 +114,9 @@ public final class PacketHandler {
|
|||
};
|
||||
public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler() {
|
||||
@Override
|
||||
|
||||
public void handleData(CompoundTag compound, IPayloadContext context) {
|
||||
CompoundTag dataTag = compound.getCompound("Data");
|
||||
Player player = context.player(); //ActuallyAdditions.PROXY.getCurrentPlayer();
|
||||
|
||||
if (player != null) {
|
||||
PlayerData.getDataFromPlayer(player).readFromNBT(dataTag, false);
|
||||
|
||||
if (compound.getBoolean("Log")) {
|
||||
ActuallyAdditions.LOGGER.info("Receiving (new or changed) Player Data for player " + player.getName() + ".");
|
||||
}
|
||||
} else {
|
||||
ActuallyAdditions.LOGGER.error("Tried to receive Player Data for the current player, but he doesn't seem to be present!");
|
||||
if(context.flow() == PacketFlow.CLIENTBOUND) {
|
||||
PacketHelperClient.handlePlayerUpdate(compound, context);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -169,10 +142,10 @@ public final class PacketHandler {
|
|||
WorldData.get(level).setDirty();
|
||||
|
||||
if (compound.getBoolean("Log")) {
|
||||
ActuallyAdditions.LOGGER.info("Receiving changed Player Data for player " + player.getName() + ".");
|
||||
ActuallyAdditions.LOGGER.info("Receiving changed Player Data for player {}.", player.getName());
|
||||
}
|
||||
} else {
|
||||
ActuallyAdditions.LOGGER.error("Tried to receive Player Data for UUID " + compound.getUUID("UUID") + ", but he doesn't seem to be present!");
|
||||
ActuallyAdditions.LOGGER.error("Tried to receive Player Data for UUID {}, but he doesn't seem to be present!", compound.getUUID("UUID"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* This file ("PacketHandlerHelper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* This file ("PacketHelperClient.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
|
@ -12,19 +12,69 @@ package de.ellpeck.actuallyadditions.mod.network;
|
|||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.particle.ParticleLaserItem;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
|
||||
public final class PacketHandlerHelper {
|
||||
public final class PacketHelperClient {
|
||||
public static void handleLaser(CompoundTag compound, IPayloadContext context) {
|
||||
AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInt("Color"), compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha"));
|
||||
}
|
||||
|
||||
public static void handleTileUpdate(CompoundTag compound, IPayloadContext context) {
|
||||
Level world = Minecraft.getInstance().level;
|
||||
if (world != null) {
|
||||
BlockEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z")));
|
||||
if (tile instanceof TileEntityBase tileBase) {
|
||||
tileBase.readSyncableNBT(compound.getCompound("Data"), world.registryAccess(), TileEntityBase.NBTType.SYNC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleLaserParticle(CompoundTag compound, IPayloadContext context) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemStack stack = ItemStack.parseOptional(context.player().registryAccess(), compound);
|
||||
|
||||
double inX = compound.getDouble("InX") + 0.5;
|
||||
double inY = compound.getDouble("InY") + 0.78;
|
||||
double inZ = compound.getDouble("InZ") + 0.5;
|
||||
|
||||
double outX = compound.getDouble("OutX") + 0.5;
|
||||
double outY = compound.getDouble("OutY") + 0.525;
|
||||
double outZ = compound.getDouble("OutZ") + 0.5;
|
||||
|
||||
mc.level.addParticle(ParticleLaserItem.Factory.createData(stack, inX, inY, inZ),
|
||||
outX, outY, outZ, 0, 0.025, 0);
|
||||
}
|
||||
|
||||
public static void handlePlayerUpdate(CompoundTag compound, IPayloadContext context) {
|
||||
CompoundTag dataTag = compound.getCompound("Data");
|
||||
Player player = context.player(); //ActuallyAdditions.PROXY.getCurrentPlayer();
|
||||
|
||||
if (player != null) {
|
||||
PlayerData.getDataFromPlayer(player).readFromNBT(dataTag, false);
|
||||
|
||||
if (compound.getBoolean("Log")) {
|
||||
ActuallyAdditions.LOGGER.info("Receiving (new or changed) Player Data for player {}.", player.getName());
|
||||
}
|
||||
} else {
|
||||
ActuallyAdditions.LOGGER.error("Tried to receive Player Data for the current player, but he doesn't seem to be present!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void sendButtonPacket(BlockEntity tile, int buttonId) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
BlockPos pos = tile.getBlockPos();
|
||||
|
@ -37,20 +87,6 @@ public final class PacketHandlerHelper {
|
|||
PacketDistributor.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
|
||||
public static void syncPlayerData(Player player, boolean log) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putBoolean("Log", log);
|
||||
|
||||
CompoundTag data = new CompoundTag();
|
||||
PlayerData.getDataFromPlayer(player).writeToNBT(data, false);
|
||||
compound.put("Data", data);
|
||||
|
||||
if (player instanceof ServerPlayer) {
|
||||
((ServerPlayer) player).connection.send(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void sendPlayerDataToServer(boolean log, int type) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putBoolean("Log", log);
|
||||
|
@ -86,7 +122,7 @@ public final class PacketHandlerHelper {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void sendNumberPacket(BlockEntity tile, double number, int id) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putInt("X", tile.getBlockPos().getX());
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* This file ("PacketHandlerHelper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketServerToClient;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
/**
|
||||
* A helper class for sending packets from the server to the client.
|
||||
*/
|
||||
public final class PacketHelperServer {
|
||||
|
||||
public static void syncPlayerData(Player player, boolean log) {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putBoolean("Log", log);
|
||||
|
||||
CompoundTag data = new CompoundTag();
|
||||
PlayerData.getDataFromPlayer(player).writeToNBT(data, false);
|
||||
compound.put("Data", data);
|
||||
ActuallyAdditions.LOGGER.info("Sending data {}", data);
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.connection.send(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,9 +8,11 @@
|
|||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
package de.ellpeck.actuallyadditions.mod.network.packet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.network.IDataHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
|
@ -8,9 +8,11 @@
|
|||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
package de.ellpeck.actuallyadditions.mod.network.packet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.network.IDataHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
@ -62,7 +64,7 @@ public record PacketServerToClient(CompoundTag data, IDataHandler handler) imple
|
|||
if (message.data != null && message.handler != null) {
|
||||
message.handler.handleData(message.data, context);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.neoforged.neoforge.energy.EnergyStorage;
|
||||
|
||||
public class CustomEnergyStorage extends EnergyStorage {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator;
|
||||
|
|
|
@ -13,17 +13,13 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
||||
|
||||
public abstract class TileEntityInventoryBase extends TileEntityBase {
|
||||
|
|
|
@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||
|
|
|
@ -140,11 +140,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
@Override
|
||||
public boolean hasBoundPosition() {
|
||||
if (this.boundPosition != null) {
|
||||
if (this.level.getBlockEntity(this.boundPosition) instanceof IPhantomTile || this.getBlockPos().getX() == this.boundPosition.getX() && this.getBlockPos().getY() == this.boundPosition.getY() && this.getBlockPos().getZ() == this.boundPosition.getZ() && this.level.dimensionType() == this.level.dimensionType()) {
|
||||
if (this.level.getBlockEntity(this.boundPosition) instanceof IPhantomTile || this.getBlockPos().getX() == this.boundPosition.getX() && this.getBlockPos().getY() == this.boundPosition.getY() && this.getBlockPos().getZ() == this.boundPosition.getZ()) { // && this.level.dimensionType() == this.level.dimensionType()
|
||||
this.boundPosition = null;
|
||||
return false;
|
||||
}
|
||||
return this.level.dimensionType() == this.level.dimensionType();
|
||||
return true;//this.level.dimensionType() == this.level.dimensionType();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.mojang.math.Axis;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderTypes;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.network.packet.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -199,7 +199,7 @@ public final class WorldUtil {
|
|||
//setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something that places Blocks at " + offsetPos.getX() + ", " + offsetPos.getY() + ", " + offsetPos.getZ() + " in World " + level.dimension() + " threw an Exception! Don't let that happen again!", e);
|
||||
ActuallyAdditions.LOGGER.error("Something that places Blocks at {}, {}, {} in World {} threw an Exception! Don't let that happen again!", offsetPos.getX(), offsetPos.getY(), offsetPos.getZ(), level.dimension(), e);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
# 1.3.4+mc1.21.1
|
||||
* Fix the way the Atomic Reconstructor handles the level when adding tooltips. Fixes an issue that would cause CM2E to crash
|
||||
|
||||
# 1.3.3+mc1.21.1
|
||||
* Fix crash on server start
|
||||
|
||||
# 1.3.2+mc1.21.1
|
||||
* Fix the gui of the Energizer/Enervator crashing
|
||||
|
||||
|
|
Loading…
Reference in a new issue