修改雷达的gui渲染
This commit is contained in:
parent
ff29686cdb
commit
20a5ae050c
5 changed files with 60 additions and 6 deletions
|
@ -175,6 +175,7 @@ public class ModUtils {
|
||||||
addNetworkMessage(MeleeAttackMessage.class, MeleeAttackMessage::encode, MeleeAttackMessage::decode, MeleeAttackMessage::handler);
|
addNetworkMessage(MeleeAttackMessage.class, MeleeAttackMessage::encode, MeleeAttackMessage::decode, MeleeAttackMessage::handler);
|
||||||
addNetworkMessage(ResetCameraTypeMessage.class, ResetCameraTypeMessage::encode, ResetCameraTypeMessage::decode, ResetCameraTypeMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(ResetCameraTypeMessage.class, ResetCameraTypeMessage::encode, ResetCameraTypeMessage::decode, ResetCameraTypeMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
addNetworkMessage(SwitchVehicleWeaponMessage.class, SwitchVehicleWeaponMessage::encode, SwitchVehicleWeaponMessage::decode, SwitchVehicleWeaponMessage::handler);
|
addNetworkMessage(SwitchVehicleWeaponMessage.class, SwitchVehicleWeaponMessage::encode, SwitchVehicleWeaponMessage::decode, SwitchVehicleWeaponMessage::handler);
|
||||||
|
addNetworkMessage(RadarSetTargetMessage.class, RadarSetTargetMessage::encode, RadarSetTargetMessage::decode, RadarSetTargetMessage::handler);
|
||||||
|
|
||||||
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
||||||
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
||||||
|
|
|
@ -38,6 +38,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FuMO25BlockEntity extends BlockEntity implements MenuProvider, GeoBlockEntity {
|
public class FuMO25BlockEntity extends BlockEntity implements MenuProvider, GeoBlockEntity {
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public static final int MAX_ENERGY = 1000000;
|
public static final int MAX_ENERGY = 1000000;
|
||||||
|
@ -230,7 +231,6 @@ public class FuMO25BlockEntity extends BlockEntity implements MenuProvider, GeoB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) {
|
public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -244,6 +244,4 @@ public class FuMO25BlockEntity extends BlockEntity implements MenuProvider, GeoB
|
||||||
GLOW,
|
GLOW,
|
||||||
GUIDE
|
GUIDE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.atsuishio.superbwarfare.menu.FuMO25Menu;
|
||||||
import com.atsuishio.superbwarfare.network.message.RadarChangeModeMessage;
|
import com.atsuishio.superbwarfare.network.message.RadarChangeModeMessage;
|
||||||
import com.atsuishio.superbwarfare.network.message.RadarSetParametersMessage;
|
import com.atsuishio.superbwarfare.network.message.RadarSetParametersMessage;
|
||||||
import com.atsuishio.superbwarfare.network.message.RadarSetPosMessage;
|
import com.atsuishio.superbwarfare.network.message.RadarSetPosMessage;
|
||||||
|
import com.atsuishio.superbwarfare.network.message.RadarSetTargetMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
@ -277,7 +278,7 @@ public class FuMO25Screen extends AbstractContainerScreen<FuMO25Menu> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
static class LockButton extends AbstractButton {
|
class LockButton extends AbstractButton {
|
||||||
|
|
||||||
public LockButton(int pX, int pY) {
|
public LockButton(int pX, int pY) {
|
||||||
super(pX, pY, 29, 15, Component.literal(""));
|
super(pX, pY, 29, 15, Component.literal(""));
|
||||||
|
@ -285,12 +286,20 @@ public class FuMO25Screen extends AbstractContainerScreen<FuMO25Menu> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPress() {
|
public void onPress() {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new RadarSetParametersMessage((byte) 0));
|
if (FuMO25Screen.this.menu.getFuncType() == 3 && FuMO25Screen.this.menu.getSlot(0).getItem().isEmpty()) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new RadarSetTargetMessage((byte) 0));
|
||||||
|
} else {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new RadarSetParametersMessage((byte) 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
protected void renderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
||||||
pGuiGraphics.blit(TEXTURE, this.getX(), this.getY(), 148, this.isHovered() ? 183 : 167, 29, 15, 358, 328);
|
if (FuMO25Screen.this.menu.getFuncType() == 3 && FuMO25Screen.this.menu.getSlot(0).getItem().isEmpty()) {
|
||||||
|
pGuiGraphics.blit(TEXTURE, this.getX(), this.getY(), 148, this.isHovered() ? 311 : 295, 29, 15, 358, 328);
|
||||||
|
} else {
|
||||||
|
pGuiGraphics.blit(TEXTURE, this.getX(), this.getY(), 148, this.isHovered() ? 183 : 167, 29, 15, 358, 328);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -96,6 +96,10 @@ public class FuMO25Menu extends EnergyMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTargetToLaserTower() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockPos getCurrentPos() {
|
public BlockPos getCurrentPos() {
|
||||||
if (this.posX != Integer.MIN_VALUE && this.posY != Integer.MIN_VALUE && this.posZ != Integer.MIN_VALUE) {
|
if (this.posX != Integer.MIN_VALUE && this.posY != Integer.MIN_VALUE && this.posZ != Integer.MIN_VALUE) {
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.menu.FuMO25Menu;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class RadarSetTargetMessage {
|
||||||
|
|
||||||
|
private final byte mode;
|
||||||
|
|
||||||
|
public RadarSetTargetMessage(byte mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(RadarSetTargetMessage message, FriendlyByteBuf buffer) {
|
||||||
|
buffer.writeByte(message.mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RadarSetTargetMessage decode(FriendlyByteBuf buffer) {
|
||||||
|
return new RadarSetTargetMessage(buffer.readByte());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handler(RadarSetTargetMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
|
ServerPlayer player = ctx.get().getSender();
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
|
AbstractContainerMenu menu = player.containerMenu;
|
||||||
|
if (menu instanceof FuMO25Menu fuMO25Menu) {
|
||||||
|
if (!player.containerMenu.stillValid(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
System.out.println(123);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ctx.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue