Merged more parts

This commit is contained in:
Sebastian Hartte
2020-07-02 12:19:41 +02:00
parent 75234415ac
commit 295e720d37
17 changed files with 26 additions and 28 deletions
@@ -27,6 +27,8 @@ import java.util.function.Function;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.util.Pair;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.UnbakedModel;
@@ -44,6 +46,7 @@ import javax.annotation.Nullable;
/**
* The built-in model for the cable bus block.
*/
@Environment(EnvType.CLIENT)
public class CableBusModel implements UnbakedModel {
private final PartModels partModels;
@@ -34,7 +34,12 @@ import appeng.items.parts.ColoredPartItem;
import appeng.items.parts.PartItem;
import appeng.items.parts.PartItemRendering;
import appeng.parts.misc.CableAnchorPart;
import appeng.parts.misc.InvertedToggleBusPart;
import appeng.parts.misc.ToggleBusPart;
import appeng.parts.networking.*;
import appeng.parts.reporting.DarkPanelPart;
import appeng.parts.reporting.PanelPart;
import appeng.parts.reporting.SemiDarkPanelPart;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
@@ -98,14 +103,14 @@ public final class ApiParts implements IParts {
this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable",
SmartDenseCablePart::new);
this.quartzFiber = createPart(registry, "quartz_fiber", QuartzFiberPart::new);
// FIXME this.toggleBus = createPart(registry, "toggle_bus", ToggleBusPart::new);
// FIXME this.invertedToggleBus = createPart(registry, "inverted_toggle_bus",
// FIXME InvertedToggleBusPart::new);
this.toggleBus = createPart(registry, "toggle_bus", ToggleBusPart::new);
this.invertedToggleBus = createPart(registry, "inverted_toggle_bus",
InvertedToggleBusPart::new);
this.cableAnchor = createPart(registry, "cable_anchor", CableAnchorPart::new);
// FIXME this.monitor = createPart(registry, "monitor", PanelPart::new);
// FIXME this.semiDarkMonitor = createPart(registry, "semi_dark_monitor",
// FIXME SemiDarkPanelPart::new);
// FIXME this.darkMonitor = createPart(registry, "dark_monitor", DarkPanelPart::new);
this.monitor = createPart(registry, "monitor", PanelPart::new);
this.semiDarkMonitor = createPart(registry, "semi_dark_monitor",
SemiDarkPanelPart::new);
this.darkMonitor = createPart(registry, "dark_monitor", DarkPanelPart::new);
// FIXME this.storageBus = createPart(registry, "storage_bus", StorageBusPart::new);
// FIXME this.fluidStorageBus = createPart(registry, "fluid_storage_bus",
// FIXME FluidStorageBusPart::new);
@@ -165,9 +170,9 @@ public final class ApiParts implements IParts {
"parts/fluid_formation_plane_on");
// Register all part models
// FIXME FABRIC for (PartType partType : PartType.values()) {
// FIXME FABRIC partModels.registerModels(partType.getModels());
// FIXME FABRIC }
for (PartType partType : PartType.values()) {
partModels.registerModels(partType.getModels());
}
}
private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id,
@@ -0,0 +1,109 @@
/*
* 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.parts;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.me.GridAccessException;
public abstract class BasicStatePart extends AEBasePart implements IPowerChannelState {
protected static final int POWERED_FLAG = 1;
protected static final int CHANNEL_FLAG = 2;
private int clientFlags = 0; // sent as byte.
public BasicStatePart(final ItemStack is) {
super(is);
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
}
@MENetworkEventSubscribe
public void chanRender(final MENetworkChannelsChanged c) {
this.getHost().markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender(final MENetworkPowerStatusChange c) {
this.getHost().markForUpdate();
}
@Override
public void writeToStream(final PacketByteBuf data) throws IOException {
super.writeToStream(data);
this.setClientFlags(0);
try {
if (this.getProxy().getEnergy().isNetworkPowered()) {
this.setClientFlags(this.getClientFlags() | POWERED_FLAG);
}
if (this.getProxy().getNode().meetsChannelRequirements()) {
this.setClientFlags(this.getClientFlags() | CHANNEL_FLAG);
}
this.setClientFlags(this.populateFlags(this.getClientFlags()));
} catch (final GridAccessException e) {
// meh
}
data.writeByte((byte) this.getClientFlags());
}
protected int populateFlags(final int cf) {
return cf;
}
@Override
public boolean readFromStream(final PacketByteBuf data) throws IOException {
final boolean eh = super.readFromStream(data);
final int old = this.getClientFlags();
this.setClientFlags(data.readByte());
return eh || old != this.getClientFlags();
}
@Override
public boolean isPowered() {
return (this.getClientFlags() & POWERED_FLAG) == POWERED_FLAG;
}
@Override
public boolean isActive() {
return (this.getClientFlags() & CHANNEL_FLAG) == CHANNEL_FLAG;
}
public int getClientFlags() {
return this.clientFlags;
}
private void setClientFlags(final int clientFlags) {
this.clientFlags = clientFlags;
}
}
@@ -0,0 +1,62 @@
/*
* 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.parts.misc;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import appeng.api.parts.IPartModel;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.parts.PartModel;
public class InvertedToggleBusPart extends ToggleBusPart {
@PartModels
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID,
"part/inverted_toggle_bus_base");
public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_STATUS_OFF);
public static final PartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_STATUS_ON);
public static final PartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL);
public InvertedToggleBusPart(final ItemStack is) {
super(is);
this.getProxy().setIdlePowerUsage(0.0);
this.getOuterProxy().setIdlePowerUsage(0.0);
this.getProxy().setFlags();
this.getOuterProxy().setFlags();
}
@Override
protected boolean getIntention() {
return !super.getIntention();
}
@Override
public IPartModel getStaticModels() {
if (this.hasRedstoneFlag() && this.isActive() && this.isPowered()) {
return MODELS_HAS_CHANNEL;
} else if (this.hasRedstoneFlag() && this.isPowered()) {
return MODELS_ON;
} else {
return MODELS_OFF;
}
}
}
@@ -0,0 +1,197 @@
/*
* 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.parts.misc;
import java.util.EnumSet;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import appeng.api.AEApi;
import appeng.api.exceptions.FailedConnectionException;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.BasicStatePart;
import appeng.parts.PartModel;
public class ToggleBusPart extends BasicStatePart {
@PartModels
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "part/toggle_bus_base");
@PartModels
public static final Identifier MODEL_STATUS_OFF = new Identifier(AppEng.MOD_ID,
"part/toggle_bus_status_off");
@PartModels
public static final Identifier MODEL_STATUS_ON = new Identifier(AppEng.MOD_ID,
"part/toggle_bus_status_on");
@PartModels
public static final Identifier MODEL_STATUS_HAS_CHANNEL = new Identifier(AppEng.MOD_ID,
"part/toggle_bus_status_has_channel");
public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_STATUS_OFF);
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_STATUS_ON);
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL);
private static final int REDSTONE_FLAG = 4;
private final AENetworkProxy outerProxy = new AENetworkProxy(this, "outer", ItemStack.EMPTY, true);
private IGridConnection connection;
private boolean hasRedstone = false;
public ToggleBusPart(final ItemStack is) {
super(is);
this.getProxy().setIdlePowerUsage(0.0);
this.getOuterProxy().setIdlePowerUsage(0.0);
this.getProxy().setFlags();
this.getOuterProxy().setFlags();
}
@Override
protected int populateFlags(final int cf) {
return cf | (this.getIntention() ? REDSTONE_FLAG : 0);
}
public boolean hasRedstoneFlag() {
return (this.getClientFlags() & REDSTONE_FLAG) == REDSTONE_FLAG;
}
protected boolean getIntention() {
return this.getHost().hasRedstone(this.getSide());
}
@Override
public AECableType getCableConnectionType(final AEPartLocation dir) {
return AECableType.GLASS;
}
@Override
public void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(6, 6, 11, 10, 10, 16);
}
@Override
public void onneighborUpdate(BlockView w, BlockPos pos, BlockPos neighbor) {
final boolean oldHasRedstone = this.hasRedstone;
this.hasRedstone = this.getHost().hasRedstone(this.getSide());
if (this.hasRedstone != oldHasRedstone) {
this.updateInternalState();
this.getHost().markForUpdate();
}
}
@Override
public void readFromNBT(final CompoundTag extra) {
super.readFromNBT(extra);
this.getOuterProxy().readFromNBT(extra);
}
@Override
public void writeToNBT(final CompoundTag extra) {
super.writeToNBT(extra);
this.getOuterProxy().writeToNBT(extra);
}
@Override
public void removeFromWorld() {
super.removeFromWorld();
this.getOuterProxy().remove();
}
@Override
public void addToWorld() {
super.addToWorld();
this.getOuterProxy().onReady();
this.hasRedstone = this.getHost().hasRedstone(this.getSide());
this.updateInternalState();
}
@Override
public void setPartHostInfo(final AEPartLocation side, final IPartHost host, final BlockEntity tile) {
super.setPartHostInfo(side, host, tile);
this.outerProxy.setValidSides(EnumSet.of(side.getFacing()));
}
@Override
public IGridNode getExternalFacingNode() {
return this.getOuterProxy().getNode();
}
@Override
public float getCableConnectionLength(AECableType cable) {
return 5;
}
@Override
public void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held,
final AEPartLocation side) {
super.onPlacement(player, hand, held, side);
this.getOuterProxy().setOwner(player);
}
private void updateInternalState() {
final boolean intention = this.getIntention();
if (intention == (this.connection == null)) {
if (this.getProxy().getNode() != null && this.getOuterProxy().getNode() != null) {
if (intention) {
try {
this.connection = AEApi.instance().grid().createGridConnection(this.getProxy().getNode(),
this.getOuterProxy().getNode());
} catch (final FailedConnectionException e) {
// :(
AELog.debug(e);
}
} else {
this.connection.destroy();
this.connection = null;
}
}
}
}
AENetworkProxy getOuterProxy() {
return this.outerProxy;
}
@Override
public IPartModel getStaticModels() {
if (this.hasRedstoneFlag() && this.isActive() && this.isPowered()) {
return MODELS_HAS_CHANNEL;
} else if (this.hasRedstoneFlag() && this.isPowered()) {
return MODELS_ON;
} else {
return MODELS_OFF;
}
}
}
@@ -0,0 +1,62 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import appeng.api.util.AEColor;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
/**
* A very simple part for emitting light.
*
* Opposed to the other subclass of {@link AbstractReportingPart}, it will only
* use the bright front texture.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPanelPart extends AbstractReportingPart {
@PartModels
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "part/monitor_base");
public AbstractPanelPart(final ItemStack is) {
super(is, false);
}
@Override
public boolean isLightSource() {
return true;
}
/**
* How bright the color the panel should appear. Usually it depends on a
* {@link AEColor} variant. This does not affect the actual light level of the
* part.
*
* @return the brightness to be used.
*/
protected abstract int getBrightnessColor();
}
@@ -0,0 +1,279 @@
/*
* 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.parts.reporting;
import java.io.IOException;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.implementations.parts.IMonitorPart;
import appeng.api.networking.GridFlags;
import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.util.AEPartLocation;
import appeng.me.GridAccessException;
import appeng.parts.AEBasePart;
import appeng.util.Platform;
/**
* The most basic class for any part reporting information, like terminals or
* monitors. This can also include basic panels which just provide light.
*
* It deals with the most basic functionalities like network data, grid
* registration or the rotation of the actual part.
*
* The direct abstract subclasses are usually a better entry point for adding
* new concrete ones. But this might be an ideal starting point to completely
* new type, which does not resemble any existing one.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractReportingPart extends AEBasePart implements IMonitorPart, IPowerChannelState {
protected static final int POWERED_FLAG = 4;
protected static final int CHANNEL_FLAG = 16;
private static final int BOOTING_FLAG = 8;
private byte spin = 0; // 0-3
private int clientFlags = 0; // sent as byte.
private int opacity = -1;
public AbstractReportingPart(final ItemStack is) {
this(is, false);
}
protected AbstractReportingPart(final ItemStack is, final boolean requireChannel) {
super(is);
if (requireChannel) {
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
this.getProxy().setIdlePowerUsage(1.0 / 2.0);
} else {
this.getProxy().setIdlePowerUsage(1.0 / 16.0); // lights drain a little bit.
}
}
@MENetworkEventSubscribe
public final void bootingRender(final MENetworkBootingStatusChange c) {
if (!this.isLightSource()) {
this.getHost().markForUpdate();
}
}
@MENetworkEventSubscribe
public final void powerRender(final MENetworkPowerStatusChange c) {
this.getHost().markForUpdate();
}
@Override
public final void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(2, 2, 14, 14, 14, 16);
bch.addBox(4, 4, 13, 12, 12, 14);
}
@Override
public void onneighborUpdate(BlockView w, BlockPos pos, BlockPos neighbor) {
if (pos.offset(this.getSide().getFacing()).equals(neighbor)) {
this.opacity = -1;
this.getHost().markForUpdate();
}
}
@Override
public void readFromNBT(final CompoundTag data) {
super.readFromNBT(data);
this.spin = data.getByte("spin");
}
@Override
public void writeToNBT(final CompoundTag data) {
super.writeToNBT(data);
data.putByte("spin", this.getSpin());
}
@Override
public void writeToStream(final PacketByteBuf data) throws IOException {
super.writeToStream(data);
this.clientFlags = this.getSpin() & 3;
try {
if (this.getProxy().getEnergy().isNetworkPowered()) {
this.clientFlags = this.getClientFlags() | AbstractReportingPart.POWERED_FLAG;
}
if (this.getProxy().getPath().isNetworkBooting()) {
this.clientFlags = this.getClientFlags() | AbstractReportingPart.BOOTING_FLAG;
}
if (this.getProxy().getNode().meetsChannelRequirements()) {
this.clientFlags = this.getClientFlags() | AbstractReportingPart.CHANNEL_FLAG;
}
} catch (final GridAccessException e) {
// um.. nothing.
}
data.writeByte((byte) this.getClientFlags());
data.writeInt(this.opacity);
}
@Override
public boolean readFromStream(final PacketByteBuf data) throws IOException {
super.readFromStream(data);
final int oldFlags = this.getClientFlags();
final int oldOpacity = this.opacity;
this.clientFlags = data.readByte();
this.opacity = data.readInt();
this.spin = (byte) (this.getClientFlags() & 3);
if (this.getClientFlags() == oldFlags && this.opacity == oldOpacity) {
return false;
}
return true;
}
@Override
public final int getLightLevel() {
return this.blockLight(this.isPowered() ? (this.isLightSource() ? 15 : 9) : 0);
}
@Override
public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) {
final BlockEntity te = this.getTile();
if (Platform.isWrench(player, player.inventory.getMainHandStack(), te.getPos())) {
if (Platform.isServer()) {
if (this.getSpin() > 3) {
this.spin = 0;
}
switch (this.getSpin()) {
case 0:
this.spin = 1;
break;
case 1:
this.spin = 3;
break;
case 2:
this.spin = 0;
break;
case 3:
this.spin = 2;
break;
}
this.getHost().markForUpdate();
this.saveChanges();
}
return true;
} else {
return super.onPartActivate(player, hand, pos);
}
}
@Override
public final void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held,
final AEPartLocation side) {
super.onPlacement(player, hand, held, side);
final byte rotation = (byte) (MathHelper.floor((player.yaw * 4F) / 360F + 2.5D) & 3);
if (side == AEPartLocation.UP) {
this.spin = rotation;
} else if (side == AEPartLocation.DOWN) {
this.spin = rotation;
}
}
private final int blockLight(final int emit) {
if (this.opacity < 0) {
final BlockEntity te = this.getTile();
World world = te.getWorld();
BlockPos pos = te.getPos().offset(this.getSide().getFacing());
this.opacity = 255 - world.getBlockState(pos).getOpacity(world, pos);
}
return (int) (emit * (this.opacity / 255.0f));
}
@Override
public final boolean isPowered() {
try {
if (Platform.isServer()) {
return this.getProxy().getEnergy().isNetworkPowered();
} else {
return ((this.getClientFlags() & PanelPart.POWERED_FLAG) == PanelPart.POWERED_FLAG);
}
} catch (final GridAccessException e) {
return false;
}
}
@Override
public final boolean isActive() {
if (!this.isLightSource()) {
return ((this.getClientFlags()
& (PanelPart.CHANNEL_FLAG | PanelPart.POWERED_FLAG)) == (PanelPart.CHANNEL_FLAG
| PanelPart.POWERED_FLAG));
} else {
return this.isPowered();
}
}
protected IPartModel selectModel(IPartModel offModels, IPartModel onModels, IPartModel hasChannelModels) {
if (this.isActive()) {
return hasChannelModels;
} else if (this.isPowered()) {
return onModels;
} else {
return offModels;
}
}
public final int getClientFlags() {
return this.clientFlags;
}
public final byte getSpin() {
return this.spin;
}
/**
* Should the part emit light. This actually only affects the light level, light
* source use a level of 15 and non light source 9.
*/
public abstract boolean isLightSource();
}
@@ -0,0 +1,53 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import appeng.api.parts.IPartModel;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.parts.PartModel;
public class DarkPanelPart extends AbstractPanelPart {
@PartModels
public static final Identifier MODEL_OFF = new Identifier(AppEng.MOD_ID, "part/monitor_dark_off");
@PartModels
public static final Identifier MODEL_ON = new Identifier(AppEng.MOD_ID, "part/monitor_dark_on");
public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF);
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON);
public DarkPanelPart(final ItemStack is) {
super(is);
}
@Override
protected int getBrightnessColor() {
return this.getColor().mediumVariant;
}
@Override
public IPartModel getStaticModels() {
return this.isPowered() ? MODELS_ON : MODELS_OFF;
}
}
@@ -0,0 +1,53 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import appeng.api.parts.IPartModel;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.parts.PartModel;
public class PanelPart extends AbstractPanelPart {
@PartModels
public static final Identifier MODEL_OFF = new Identifier(AppEng.MOD_ID, "part/monitor_bright_off");
@PartModels
public static final Identifier MODEL_ON = new Identifier(AppEng.MOD_ID, "part/monitor_bright_on");
public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF);
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON);
public PanelPart(final ItemStack is) {
super(is);
}
@Override
protected int getBrightnessColor() {
return this.getColor().whiteVariant;
}
@Override
public IPartModel getStaticModels() {
return this.isPowered() ? MODELS_ON : MODELS_OFF;
}
}
@@ -0,0 +1,56 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import appeng.api.parts.IPartModel;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.parts.PartModel;
public class SemiDarkPanelPart extends AbstractPanelPart {
@PartModels
public static final Identifier MODEL_OFF = new Identifier(AppEng.MOD_ID, "part/monitor_medium_off");
@PartModels
public static final Identifier MODEL_ON = new Identifier(AppEng.MOD_ID, "part/monitor_medium_on");
public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF);
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON);
public SemiDarkPanelPart(final ItemStack is) {
super(is);
}
@Override
protected int getBrightnessColor() {
final int light = this.getColor().whiteVariant;
final int dark = this.getColor().mediumVariant;
return (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16)
| (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8)
| ((((light) & 0xff) + ((dark) & 0xff)) / 2);
}
@Override
public IPartModel getStaticModels() {
return this.isPowered() ? MODELS_ON : MODELS_OFF;
}
}