Fix identity annihilation plane.
Added annihilation plane blacklist tags. Moved to using loot-table item generation for annihilation plane. Play fluid pickup sound rather than block break sound for fluid annihilation planes. Do not play a second block break sound (the server already does).
This commit is contained in:
@@ -24,31 +24,7 @@ import java.util.function.Function;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.core.sync.packets.PacketCompassRequest;
|
||||
import appeng.core.sync.packets.PacketCompassResponse;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketFluidSlot;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.core.sync.packets.PacketProgressBar;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketTargetFluidStack;
|
||||
import appeng.core.sync.packets.PacketTargetItemStack;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.core.sync.packets.*;
|
||||
|
||||
public class AppEngPacketHandlerBase {
|
||||
private static final Map<Class<? extends AppEngPacket>, PacketTypes> REVERSE_LOOKUP = new HashMap<>();
|
||||
@@ -76,7 +52,9 @@ public class AppEngPacketHandlerBase {
|
||||
|
||||
PACKET_VALUE_CONFIG(PacketValueConfig.class, PacketValueConfig::new),
|
||||
|
||||
PACKET_TRANSITION_EFFECT(PacketTransitionEffect.class, PacketTransitionEffect::new),
|
||||
PACKET_ITEM_TRANSITION_EFFECT(PacketItemTransitionEffect.class, PacketItemTransitionEffect::new),
|
||||
|
||||
PACKET_BLOCK_TRANSITION_EFFECT(PacketBlockTransitionEffect.class, PacketBlockTransitionEffect::new),
|
||||
|
||||
PACKET_PROGRESS_VALUE(PacketProgressBar.class, PacketProgressBar::new),
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SimpleSound;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.effects.EnergyParticleData;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* Plays the block breaking or fluid pickup sound and a transition particle
|
||||
* effect into the supplied direction. Used primarily by annihilation planes.
|
||||
*/
|
||||
public class PacketBlockTransitionEffect extends AppEngPacket {
|
||||
|
||||
private final BlockPos pos;
|
||||
private final BlockState blockState;
|
||||
private final AEPartLocation direction;
|
||||
private final SoundMode soundMode;
|
||||
|
||||
public enum SoundMode {
|
||||
BLOCK, FLUID, NONE
|
||||
}
|
||||
|
||||
public PacketBlockTransitionEffect(BlockPos pos, BlockState blockState, AEPartLocation direction,
|
||||
SoundMode soundMode) {
|
||||
this.pos = pos;
|
||||
this.blockState = blockState;
|
||||
this.direction = direction;
|
||||
this.soundMode = soundMode;
|
||||
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeBlockPos(pos);
|
||||
int blockStateId = GameData.getBlockStateIDMap().get(blockState);
|
||||
if (blockStateId == -1) {
|
||||
AELog.warn("Failed to find numeric id for block state %s", blockState);
|
||||
}
|
||||
data.writeInt(blockStateId);
|
||||
data.writeByte(this.direction.ordinal());
|
||||
data.writeByte((byte) soundMode.ordinal());
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
public PacketBlockTransitionEffect(final PacketBuffer stream) {
|
||||
|
||||
this.pos = stream.readBlockPos();
|
||||
int blockStateId = stream.readInt();
|
||||
BlockState blockState = GameData.getBlockStateIDMap().getByValue(blockStateId);
|
||||
if (blockState == null) {
|
||||
AELog.warn("Received invalid blockstate id %d from server", blockStateId);
|
||||
blockState = Blocks.AIR.getDefaultState();
|
||||
}
|
||||
this.blockState = blockState;
|
||||
this.direction = AEPartLocation.fromOrdinal(stream.readByte());
|
||||
this.soundMode = SoundMode.values()[stream.readByte()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
spawnParticles();
|
||||
|
||||
playBreakOrPickupSound();
|
||||
}
|
||||
|
||||
private void spawnParticles() {
|
||||
|
||||
EnergyParticleData data = new EnergyParticleData(false, direction);
|
||||
for (int zz = 0; zz < 32; zz++) {
|
||||
if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) {
|
||||
// Distribute the spawn point across the entire block's area
|
||||
double x = pos.getX() + Platform.getRandomFloat();
|
||||
double y = pos.getY() + Platform.getRandomFloat();
|
||||
double z = pos.getZ() + Platform.getRandomFloat();
|
||||
double speedX = 0.1f * this.direction.xOffset;
|
||||
double speedY = 0.1f * this.direction.yOffset;
|
||||
double speedZ = 0.1f * this.direction.zOffset;
|
||||
|
||||
Minecraft.getInstance().particles.addParticle(data, x, y, z, speedX, speedY, speedZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playBreakOrPickupSound() {
|
||||
|
||||
SoundEvent soundEvent;
|
||||
float volume;
|
||||
float pitch;
|
||||
if (soundMode == SoundMode.FLUID) {
|
||||
// This code is based on what BucketItem does
|
||||
Fluid fluid = blockState.getFluidState().getFluid();
|
||||
soundEvent = fluid.getAttributes().getFillSound();
|
||||
if (soundEvent == null) {
|
||||
if (fluid.isIn(FluidTags.LAVA)) {
|
||||
soundEvent = SoundEvents.ITEM_BUCKET_FILL_LAVA;
|
||||
} else {
|
||||
soundEvent = SoundEvents.ITEM_BUCKET_FILL;
|
||||
}
|
||||
}
|
||||
volume = 1;
|
||||
pitch = 1;
|
||||
} else if (soundMode == SoundMode.BLOCK) {
|
||||
SoundType soundType = blockState.getSoundType();
|
||||
soundEvent = soundType.getBreakSound();
|
||||
volume = soundType.volume;
|
||||
pitch = soundType.pitch;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleSound sound = new SimpleSound(soundEvent, SoundCategory.BLOCKS, (volume + 1.0F) / 2.0F, pitch * 0.8F,
|
||||
pos);
|
||||
Minecraft.getInstance().getSoundHandler().play(sound);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.effects.EnergyParticleData;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* Plays a transition particle effect into the supplied direction. Used
|
||||
* primarily by annihilation planes.
|
||||
*/
|
||||
public class PacketItemTransitionEffect extends AppEngPacket {
|
||||
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final AEPartLocation d;
|
||||
|
||||
public PacketItemTransitionEffect(double x, double y, double z, AEPartLocation direction) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.d = direction;
|
||||
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeFloat((float) x);
|
||||
data.writeFloat((float) y);
|
||||
data.writeFloat((float) z);
|
||||
data.writeByte(this.d.ordinal());
|
||||
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
public PacketItemTransitionEffect(final PacketBuffer stream) {
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
this.d = AEPartLocation.fromOrdinal(stream.readByte());
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
|
||||
EnergyParticleData data = new EnergyParticleData(true, this.d);
|
||||
for (int zz = 0; zz < 8; zz++) {
|
||||
if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) {
|
||||
// Distribute the spawn point around the item's position
|
||||
double x = this.x + Platform.getRandomFloat() * 0.5 - 0.25;
|
||||
double y = this.y + Platform.getRandomFloat() * 0.5 - 0.25;
|
||||
double z = this.z + Platform.getRandomFloat() * 0.5 - 0.25;
|
||||
double speedX = 0.1f * this.d.xOffset;
|
||||
double speedY = 0.1f * this.d.yOffset;
|
||||
double speedZ = 0.1f * this.d.zOffset;
|
||||
Minecraft.getInstance().particles.addParticle(data, x, y, z, speedX, speedY, speedZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.fluids.client.gui.GuiFluidTerminal;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -45,6 +44,7 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.client.gui.GuiFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
|
||||
/**
|
||||
@@ -137,9 +137,8 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket {
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
if( gs instanceof GuiFluidTerminal)
|
||||
{
|
||||
( (GuiFluidTerminal) gs ).postUpdate( this.list );
|
||||
if (gs instanceof GuiFluidTerminal) {
|
||||
((GuiFluidTerminal) gs).postUpdate(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SimpleSound;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.effects.EnergyFx;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketTransitionEffect extends AppEngPacket {
|
||||
|
||||
private final boolean mode;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final AEPartLocation d;
|
||||
|
||||
public PacketTransitionEffect(final PacketBuffer stream) {
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
this.d = AEPartLocation.fromOrdinal(stream.readByte());
|
||||
this.mode = stream.readBoolean();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketTransitionEffect(final double x, final double y, final double z, final AEPartLocation dir,
|
||||
final boolean wasBlock) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.d = dir;
|
||||
this.mode = wasBlock;
|
||||
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeFloat((float) x);
|
||||
data.writeFloat((float) y);
|
||||
data.writeFloat((float) z);
|
||||
data.writeByte(this.d.ordinal());
|
||||
data.writeBoolean(wasBlock);
|
||||
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
|
||||
for (int zz = 0; zz < (this.mode ? 32 : 8); zz++) {
|
||||
if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) {
|
||||
double x = this.x + (this.mode ? (Platform.getRandomInt() % 100) * 0.01
|
||||
: (Platform.getRandomInt() % 100) * 0.005 - 0.25);
|
||||
double y = this.y + (this.mode ? (Platform.getRandomInt() % 100) * 0.01
|
||||
: (Platform.getRandomInt() % 100) * 0.005 - 0.25);
|
||||
double z = this.z + (this.mode ? (Platform.getRandomInt() % 100) * 0.01
|
||||
: (Platform.getRandomInt() % 100) * 0.005 - 0.25);
|
||||
double speedX = -0.1f * this.d.xOffset;
|
||||
double speedY = -0.1f * this.d.yOffset;
|
||||
double speedZ = -0.1f * this.d.zOffset;
|
||||
|
||||
EnergyFx fx = (EnergyFx) Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, x, y, z, speedX,
|
||||
speedY, speedZ);
|
||||
// FIXME: *sigh* custom particle data for this one thing :|
|
||||
if (!this.mode) {
|
||||
fx.fromItem(this.d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mode) {
|
||||
final BlockPos pos = new BlockPos((int) this.x, (int) this.y, (int) this.z);
|
||||
final BlockState state = world.getBlockState(pos);
|
||||
final SoundType sound = state.getSoundType(world, pos, null);
|
||||
|
||||
Minecraft.getInstance().getSoundHandler()
|
||||
.play(new SimpleSound(sound.getBreakSound(), SoundCategory.BLOCKS,
|
||||
(sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F, (float) this.x + 0.5F,
|
||||
(float) this.y + 0.5F, (float) this.z + 0.5F));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user