mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-19 16:32:31 +01:00
Logistics Part III
- Fixed Redstone bridges activating inconsistently - Fixed Redstone bridges breaking on world reload - Completed the Stockpile Switch - Added Skeleton for filters - Added Skeleton for extractors - Renamed some stuff
This commit is contained in:
parent
79d160e5bc
commit
22fc9d1100
61 changed files with 1206 additions and 702 deletions
|
@ -24,14 +24,16 @@ import com.simibubi.create.modules.contraptions.relays.CogWheelBlock;
|
||||||
import com.simibubi.create.modules.contraptions.relays.EncasedBeltBlock;
|
import com.simibubi.create.modules.contraptions.relays.EncasedBeltBlock;
|
||||||
import com.simibubi.create.modules.contraptions.relays.GearboxBlock;
|
import com.simibubi.create.modules.contraptions.relays.GearboxBlock;
|
||||||
import com.simibubi.create.modules.contraptions.relays.GearshifterBlock;
|
import com.simibubi.create.modules.contraptions.relays.GearshifterBlock;
|
||||||
|
import com.simibubi.create.modules.economy.ShopShelfBlock;
|
||||||
import com.simibubi.create.modules.gardens.CocoaLogBlock;
|
import com.simibubi.create.modules.gardens.CocoaLogBlock;
|
||||||
import com.simibubi.create.modules.logistics.FlexcrateBlock;
|
import com.simibubi.create.modules.logistics.block.ExtractorBlock;
|
||||||
import com.simibubi.create.modules.logistics.RedstoneBridgeBlock;
|
import com.simibubi.create.modules.logistics.block.FlexcrateBlock;
|
||||||
import com.simibubi.create.modules.logistics.StockswitchBlock;
|
import com.simibubi.create.modules.logistics.block.LinkedExtractorBlock;
|
||||||
|
import com.simibubi.create.modules.logistics.block.RedstoneBridgeBlock;
|
||||||
|
import com.simibubi.create.modules.logistics.block.StockswitchBlock;
|
||||||
import com.simibubi.create.modules.schematics.block.CreativeCrateBlock;
|
import com.simibubi.create.modules.schematics.block.CreativeCrateBlock;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicTableBlock;
|
import com.simibubi.create.modules.schematics.block.SchematicTableBlock;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicannonBlock;
|
import com.simibubi.create.modules.schematics.block.SchematicannonBlock;
|
||||||
import com.simibubi.create.modules.shopping.ShopShelfBlock;
|
|
||||||
import com.simibubi.create.modules.symmetry.block.CrossPlaneSymmetryBlock;
|
import com.simibubi.create.modules.symmetry.block.CrossPlaneSymmetryBlock;
|
||||||
import com.simibubi.create.modules.symmetry.block.PlaneSymmetryBlock;
|
import com.simibubi.create.modules.symmetry.block.PlaneSymmetryBlock;
|
||||||
import com.simibubi.create.modules.symmetry.block.TriplePlaneSymmetryBlock;
|
import com.simibubi.create.modules.symmetry.block.TriplePlaneSymmetryBlock;
|
||||||
|
@ -94,6 +96,8 @@ public enum AllBlocks {
|
||||||
REDSTONE_BRIDGE(new RedstoneBridgeBlock()),
|
REDSTONE_BRIDGE(new RedstoneBridgeBlock()),
|
||||||
STOCKSWITCH(new StockswitchBlock()),
|
STOCKSWITCH(new StockswitchBlock()),
|
||||||
FLEXCRATE(new FlexcrateBlock()),
|
FLEXCRATE(new FlexcrateBlock()),
|
||||||
|
EXTRACTOR(new ExtractorBlock()),
|
||||||
|
LINKED_EXTRACTOR(new LinkedExtractorBlock()),
|
||||||
|
|
||||||
// Symmetry
|
// Symmetry
|
||||||
SYMMETRY_PLANE(new PlaneSymmetryBlock()),
|
SYMMETRY_PLANE(new PlaneSymmetryBlock()),
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.simibubi.create;
|
package com.simibubi.create;
|
||||||
|
|
||||||
import com.simibubi.create.modules.logistics.FlexcrateContainer;
|
import com.simibubi.create.modules.economy.ShopShelfContainer;
|
||||||
import com.simibubi.create.modules.logistics.FlexcrateScreen;
|
import com.simibubi.create.modules.economy.ShopShelfScreen;
|
||||||
|
import com.simibubi.create.modules.logistics.block.FlexcrateContainer;
|
||||||
|
import com.simibubi.create.modules.logistics.block.FlexcrateScreen;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicTableContainer;
|
import com.simibubi.create.modules.schematics.block.SchematicTableContainer;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicTableScreen;
|
import com.simibubi.create.modules.schematics.block.SchematicTableScreen;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicannonContainer;
|
import com.simibubi.create.modules.schematics.block.SchematicannonContainer;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicannonScreen;
|
import com.simibubi.create.modules.schematics.block.SchematicannonScreen;
|
||||||
import com.simibubi.create.modules.shopping.ShopShelfContainer;
|
|
||||||
import com.simibubi.create.modules.shopping.ShopShelfScreen;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.IHasContainer;
|
import net.minecraft.client.gui.IHasContainer;
|
||||||
import net.minecraft.client.gui.ScreenManager;
|
import net.minecraft.client.gui.ScreenManager;
|
||||||
|
|
|
@ -5,12 +5,14 @@ import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItem;
|
||||||
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItemRenderer;
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItemRenderer;
|
||||||
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunModel;
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunModel;
|
||||||
import com.simibubi.create.modules.gardens.TreeFertilizerItem;
|
import com.simibubi.create.modules.gardens.TreeFertilizerItem;
|
||||||
|
import com.simibubi.create.modules.logistics.item.FilterItem;
|
||||||
import com.simibubi.create.modules.schematics.item.BlueprintAndQuillItem;
|
import com.simibubi.create.modules.schematics.item.BlueprintAndQuillItem;
|
||||||
import com.simibubi.create.modules.schematics.item.BlueprintItem;
|
import com.simibubi.create.modules.schematics.item.BlueprintItem;
|
||||||
import com.simibubi.create.modules.symmetry.SymmetryWandItem;
|
import com.simibubi.create.modules.symmetry.SymmetryWandItem;
|
||||||
import com.simibubi.create.modules.symmetry.client.SymmetryWandItemRenderer;
|
import com.simibubi.create.modules.symmetry.client.SymmetryWandItemRenderer;
|
||||||
import com.simibubi.create.modules.symmetry.client.SymmetryWandModel;
|
import com.simibubi.create.modules.symmetry.client.SymmetryWandModel;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||||
|
@ -45,6 +47,7 @@ public enum AllItems {
|
||||||
BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))),
|
BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))),
|
||||||
BLUEPRINT(new BlueprintItem(standardProperties())),
|
BLUEPRINT(new BlueprintItem(standardProperties())),
|
||||||
BELT_CONNECTOR(new BeltItem(standardProperties())),
|
BELT_CONNECTOR(new BeltItem(standardProperties())),
|
||||||
|
FILTER(new FilterItem(standardProperties())),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -81,6 +84,11 @@ public enum AllItems {
|
||||||
SYMMETRY_WAND, BUILDER_GUN,;
|
SYMMETRY_WAND, BUILDER_GUN,;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static void registerColorHandlers() {
|
||||||
|
Minecraft.getInstance().getItemColors().register(new FilterItem.Color(), FILTER.item);
|
||||||
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
|
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
|
||||||
switch (renderer) {
|
switch (renderer) {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.util.function.Supplier;
|
||||||
import com.simibubi.create.foundation.packet.NbtPacket;
|
import com.simibubi.create.foundation.packet.NbtPacket;
|
||||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||||
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunBeamPacket;
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunBeamPacket;
|
||||||
|
import com.simibubi.create.modules.logistics.packet.ConfigureFlexcratePacket;
|
||||||
|
import com.simibubi.create.modules.logistics.packet.ConfigureStockswitchPacket;
|
||||||
import com.simibubi.create.modules.schematics.packet.ConfigureSchematicannonPacket;
|
import com.simibubi.create.modules.schematics.packet.ConfigureSchematicannonPacket;
|
||||||
import com.simibubi.create.modules.schematics.packet.SchematicPlacePacket;
|
import com.simibubi.create.modules.schematics.packet.SchematicPlacePacket;
|
||||||
import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket;
|
import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket;
|
||||||
|
@ -23,6 +25,8 @@ public enum AllPackets {
|
||||||
// Client to Server
|
// Client to Server
|
||||||
NBT(NbtPacket.class, NbtPacket::new),
|
NBT(NbtPacket.class, NbtPacket::new),
|
||||||
CONFIGURE_SCHEMATICANNON(ConfigureSchematicannonPacket.class, ConfigureSchematicannonPacket::new),
|
CONFIGURE_SCHEMATICANNON(ConfigureSchematicannonPacket.class, ConfigureSchematicannonPacket::new),
|
||||||
|
CONFIGURE_FLEXCRATE(ConfigureFlexcratePacket.class, ConfigureFlexcratePacket::new),
|
||||||
|
CONFIGURE_STOCKSWITCH(ConfigureStockswitchPacket.class, ConfigureStockswitchPacket::new),
|
||||||
PLACE_SCHEMATIC(SchematicPlacePacket.class, SchematicPlacePacket::new),
|
PLACE_SCHEMATIC(SchematicPlacePacket.class, SchematicPlacePacket::new),
|
||||||
UPLOAD_SCHEMATIC(SchematicUploadPacket.class, SchematicUploadPacket::new),
|
UPLOAD_SCHEMATIC(SchematicUploadPacket.class, SchematicUploadPacket::new),
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@ import com.simibubi.create.modules.contraptions.relays.GearboxTileEntity;
|
||||||
import com.simibubi.create.modules.contraptions.relays.GearboxTileEntityRenderer;
|
import com.simibubi.create.modules.contraptions.relays.GearboxTileEntityRenderer;
|
||||||
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntity;
|
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntity;
|
||||||
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntityRenderer;
|
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntityRenderer;
|
||||||
import com.simibubi.create.modules.logistics.FlexcrateTileEntity;
|
import com.simibubi.create.modules.economy.ShopShelfTileEntity;
|
||||||
import com.simibubi.create.modules.logistics.RedstoneBridgeTileEntity;
|
import com.simibubi.create.modules.logistics.block.FlexcrateTileEntity;
|
||||||
import com.simibubi.create.modules.logistics.RedstoneBridgeTileEntityRenderer;
|
import com.simibubi.create.modules.logistics.block.RedstoneBridgeTileEntity;
|
||||||
import com.simibubi.create.modules.logistics.StockswitchTileEntity;
|
import com.simibubi.create.modules.logistics.block.RedstoneBridgeTileEntityRenderer;
|
||||||
|
import com.simibubi.create.modules.logistics.block.StockswitchTileEntity;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity;
|
import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicannonRenderer;
|
import com.simibubi.create.modules.schematics.block.SchematicannonRenderer;
|
||||||
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity;
|
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity;
|
||||||
import com.simibubi.create.modules.shopping.ShopShelfTileEntity;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class Create {
|
||||||
ScrollFixer.init();
|
ScrollFixer.init();
|
||||||
TOOL_MENU = new KeyBinding("Tool Menu (Hold)", KeyboardHelper.LALT, NAME);
|
TOOL_MENU = new KeyBinding("Tool Menu (Hold)", KeyboardHelper.LALT, NAME);
|
||||||
ClientRegistry.registerKeyBinding(TOOL_MENU);
|
ClientRegistry.registerKeyBinding(TOOL_MENU);
|
||||||
|
AllItems.registerColorHandlers();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,37 +11,45 @@ public abstract class SyncedTileEntity extends TileEntity {
|
||||||
public SyncedTileEntity(TileEntityType<?> tileEntityTypeIn) {
|
public SyncedTileEntity(TileEntityType<?> tileEntityTypeIn) {
|
||||||
super(tileEntityTypeIn);
|
super(tileEntityTypeIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT getTileData() {
|
public CompoundNBT getTileData() {
|
||||||
return super.getTileData();
|
return super.getTileData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT getUpdateTag() {
|
public CompoundNBT getUpdateTag() {
|
||||||
return write(new CompoundNBT());
|
return write(new CompoundNBT());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUpdateTag(CompoundNBT tag) {
|
public void handleUpdateTag(CompoundNBT tag) {
|
||||||
read(tag);
|
read(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendData() {
|
||||||
|
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 2 | 16);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void causeBlockUpdate() {
|
||||||
public SUpdateTileEntityPacket getUpdatePacket(){
|
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 1);
|
||||||
return new SUpdateTileEntityPacket(getPos(), 1, writeToClient(new CompoundNBT()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt){
|
public SUpdateTileEntityPacket getUpdatePacket() {
|
||||||
|
return new SUpdateTileEntityPacket(getPos(), 1, writeToClient(new CompoundNBT()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
|
||||||
readClientUpdate(pkt.getNbtCompound());
|
readClientUpdate(pkt.getNbtCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special handling for client update packets
|
// Special handling for client update packets
|
||||||
public void readClientUpdate(CompoundNBT tag) {
|
public void readClientUpdate(CompoundNBT tag) {
|
||||||
read(tag);
|
read(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special handling for client update packets
|
// Special handling for client update packets
|
||||||
public CompoundNBT writeToClient(CompoundNBT tag) {
|
public CompoundNBT writeToClient(CompoundNBT tag) {
|
||||||
return write(tag);
|
return write(tag);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simibubi.create.foundation.gui.widgets;
|
package com.simibubi.create.foundation.gui.widgets;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
|
||||||
|
@ -42,6 +44,7 @@ public class Label extends AbstractSimiWidget {
|
||||||
if (text == null || text.isEmpty())
|
if (text == null || text.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GlStateManager.color4f(1, 1, 1, 1);
|
||||||
if (hasShadow)
|
if (hasShadow)
|
||||||
font.drawStringWithShadow(text + suffix, x, y, color);
|
font.drawStringWithShadow(text + suffix, x, y, color);
|
||||||
else
|
else
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.simibubi.create.foundation.packet;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||||
|
|
||||||
|
public abstract class TileEntityConfigurationPacket<TE extends SyncedTileEntity> extends SimplePacketBase {
|
||||||
|
|
||||||
|
protected BlockPos pos;
|
||||||
|
|
||||||
|
public TileEntityConfigurationPacket(PacketBuffer buffer) {
|
||||||
|
pos = buffer.readBlockPos();
|
||||||
|
readSettings(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEntityConfigurationPacket(BlockPos pos) {
|
||||||
|
this.pos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(PacketBuffer buffer) {
|
||||||
|
buffer.writeBlockPos(pos);
|
||||||
|
writeSettings(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void handle(Supplier<Context> context) {
|
||||||
|
context.get().enqueueWork(() -> {
|
||||||
|
ServerPlayerEntity player = context.get().getSender();
|
||||||
|
World world = player.world;
|
||||||
|
|
||||||
|
if (world == null || world.getTileEntity(pos) == null)
|
||||||
|
return;
|
||||||
|
TileEntity tileEntity = world.getTileEntity(pos);
|
||||||
|
if (tileEntity instanceof SyncedTileEntity) {
|
||||||
|
applySettings((TE) tileEntity);
|
||||||
|
((SyncedTileEntity) tileEntity).sendData();
|
||||||
|
tileEntity.markDirty();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
context.get().setPacketHandled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void writeSettings(PacketBuffer buffer);
|
||||||
|
protected abstract void readSettings(PacketBuffer buffer);
|
||||||
|
protected abstract void applySettings(TE te);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
|
public class ContainerListener {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -143,14 +143,14 @@ public class RotationPropagator {
|
||||||
if (neighbourTE.hasSource() && neighbourTE.getSource().equals(addedTE.getPos())) {
|
if (neighbourTE.hasSource() && neighbourTE.getSource().equals(addedTE.getPos())) {
|
||||||
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
|
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
|
||||||
addedTE.onSpeedChanged();
|
addedTE.onSpeedChanged();
|
||||||
addedTE.notifyBlockUpdate();
|
addedTE.sendData();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
|
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
|
||||||
addedTE.setSource(neighbourTE.getPos());
|
addedTE.setSource(neighbourTE.getPos());
|
||||||
addedTE.onSpeedChanged();
|
addedTE.onSpeedChanged();
|
||||||
addedTE.notifyBlockUpdate();
|
addedTE.sendData();
|
||||||
propagateNewSource(addedTE);
|
propagateNewSource(addedTE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class RotationPropagator {
|
||||||
neighbourTE.setSpeed(newSpeed);
|
neighbourTE.setSpeed(newSpeed);
|
||||||
neighbourTE.setSource(updateTE.getPos());
|
neighbourTE.setSource(updateTE.getPos());
|
||||||
neighbourTE.onSpeedChanged();
|
neighbourTE.onSpeedChanged();
|
||||||
neighbourTE.notifyBlockUpdate();
|
neighbourTE.sendData();
|
||||||
propagateNewSource(neighbourTE);
|
propagateNewSource(neighbourTE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ public class RotationPropagator {
|
||||||
final KineticTileEntity currentTE = (KineticTileEntity) world.getTileEntity(pos);
|
final KineticTileEntity currentTE = (KineticTileEntity) world.getTileEntity(pos);
|
||||||
|
|
||||||
currentTE.removeSource();
|
currentTE.removeSource();
|
||||||
currentTE.notifyBlockUpdate();
|
currentTE.sendData();
|
||||||
|
|
||||||
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
|
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
|
||||||
if (neighbourTE.isSource()) {
|
if (neighbourTE.isSource()) {
|
||||||
|
|
|
@ -51,10 +51,6 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
|
||||||
super.remove();
|
super.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyBlockUpdate() {
|
|
||||||
this.world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 2 | 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT write(CompoundNBT compound) {
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
compound.putFloat("Speed", getSpeed());
|
compound.putFloat("Speed", getSpeed());
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class WaterWheelTileEntity extends KineticTileEntity {
|
||||||
RotationPropagator.handleRemoved(world, pos, this);
|
RotationPropagator.handleRemoved(world, pos, this);
|
||||||
this.setSpeed(speed);
|
this.setSpeed(speed);
|
||||||
hasFlows = speed != 0;
|
hasFlows = speed != 0;
|
||||||
notifyBlockUpdate();
|
sendData();
|
||||||
RotationPropagator.handleAdded(world, pos, this);
|
RotationPropagator.handleAdded(world, pos, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ITi
|
||||||
offset = movingConstruct.initialExtensionProgress;
|
offset = movingConstruct.initialExtensionProgress;
|
||||||
movingPistons.add(this);
|
movingPistons.add(this);
|
||||||
|
|
||||||
notifyBlockUpdate();
|
sendData();
|
||||||
getWorld().setBlockState(pos, getBlockState().with(MechanicalPistonBlock.STATE, PistonState.MOVING), 66);
|
getWorld().setBlockState(pos, getBlockState().with(MechanicalPistonBlock.STATE, PistonState.MOVING), 66);
|
||||||
for (BlockInfo block : movingConstruct.blocks.values()) {
|
for (BlockInfo block : movingConstruct.blocks.values()) {
|
||||||
BlockPos startPos = block.pos.offset(direction, movingConstruct.initialExtensionProgress);
|
BlockPos startPos = block.pos.offset(direction, movingConstruct.initialExtensionProgress);
|
||||||
|
@ -148,7 +148,7 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ITi
|
||||||
running = false;
|
running = false;
|
||||||
movingPistons.remove(this);
|
movingPistons.remove(this);
|
||||||
movingConstruct = null;
|
movingConstruct = null;
|
||||||
notifyBlockUpdate();
|
sendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.shopping;
|
package com.simibubi.create.modules.economy;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.shopping;
|
package com.simibubi.create.modules.economy;
|
||||||
|
|
||||||
import com.simibubi.create.AllContainers;
|
import com.simibubi.create.AllContainers;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.shopping;
|
package com.simibubi.create.modules.economy;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.shopping;
|
package com.simibubi.create.modules.economy;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class ShopShelfTileEntity extends SyncedTileEntity implements INamedConta
|
||||||
private UUID owner;
|
private UUID owner;
|
||||||
|
|
||||||
public ShopShelfTileEntity() {
|
public ShopShelfTileEntity() {
|
||||||
super(AllTileEntities.ShopShelfTileEntity.type);
|
super(AllTileEntities.SHOP_SHELF.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,85 +0,0 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.InfoBlock;
|
|
||||||
import com.simibubi.create.foundation.utility.ItemDescription;
|
|
||||||
import com.simibubi.create.foundation.utility.ItemDescription.Palette;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
|
|
||||||
public class FlexcrateBlock extends InfoBlock {
|
|
||||||
|
|
||||||
public static final VoxelShape SHAPE = makeCuboidShape(1, 0, 1, 15, 14, 15);
|
|
||||||
|
|
||||||
public FlexcrateBlock() {
|
|
||||||
super(Properties.from(Blocks.ANDESITE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
|
||||||
return SHAPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTileEntity(BlockState state) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
|
||||||
BlockRayTraceResult hit) {
|
|
||||||
|
|
||||||
if (worldIn.isRemote) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
FlexcrateTileEntity te = (FlexcrateTileEntity) worldIn.getTileEntity(pos);
|
|
||||||
if (te != null)
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
|
||||||
return new FlexcrateTileEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemDescription getDescription() {
|
|
||||||
Palette color = Palette.Yellow;
|
|
||||||
return new ItemDescription(color)
|
|
||||||
.withSummary("This Storage Container allows Manual control over its capacity. It can hold up to "
|
|
||||||
+ h("16 Stacks", color) + " of Items.")
|
|
||||||
.createTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
|
||||||
if (worldIn.getTileEntity(pos) == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FlexcrateTileEntity te = (FlexcrateTileEntity) worldIn.getTileEntity(pos);
|
|
||||||
for (int slot = 0; slot < te.inventory.getSlots(); slot++) {
|
|
||||||
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(),
|
|
||||||
te.inventory.getStackInSlot(slot));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
|
||||||
worldIn.removeTileEntity(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllContainers;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.inventory.container.Container;
|
|
||||||
import net.minecraft.inventory.container.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
|
|
||||||
public class FlexcrateContainer extends Container {
|
|
||||||
|
|
||||||
public FlexcrateTileEntity te;
|
|
||||||
public PlayerInventory playerInventory;
|
|
||||||
|
|
||||||
public FlexcrateContainer(int id, PlayerInventory inv, PacketBuffer extraData) {
|
|
||||||
super(AllContainers.FlexCrate.type, id);
|
|
||||||
ClientWorld world = Minecraft.getInstance().world;
|
|
||||||
this.te = (FlexcrateTileEntity) world.getTileEntity(extraData.readBlockPos());
|
|
||||||
this.te.handleUpdateTag(extraData.readCompoundTag());
|
|
||||||
this.playerInventory = inv;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlexcrateContainer(int id, PlayerInventory inv, FlexcrateTileEntity te) {
|
|
||||||
super(AllContainers.FlexCrate.type, id);
|
|
||||||
this.te = te;
|
|
||||||
this.playerInventory = inv;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
for (int row = 0; row < 4; ++row) {
|
|
||||||
for (int col = 0; col < 4; ++col) {
|
|
||||||
this.addSlot(new SlotItemHandler(te.inventory, col + row * 4, 124 + col * 18, 25 + row * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// player Slots
|
|
||||||
int xOffset = 58;
|
|
||||||
int yOffset = 157;
|
|
||||||
for (int row = 0; row < 3; ++row) {
|
|
||||||
for (int col = 0; col < 9; ++col) {
|
|
||||||
this.addSlot(new Slot(playerInventory, col + row * 9 + 9, xOffset + col * 18, yOffset + row * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot) {
|
|
||||||
this.addSlot(new Slot(playerInventory, hotbarSlot, xOffset + hotbarSlot * 18, yOffset + 58));
|
|
||||||
}
|
|
||||||
|
|
||||||
detectAndSendChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
|
||||||
Slot clickedSlot = getSlot(index);
|
|
||||||
if (!clickedSlot.getHasStack())
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
|
|
||||||
ItemStack stack = clickedSlot.getStack();
|
|
||||||
if (index < 16)
|
|
||||||
mergeItemStack(stack, 16, inventorySlots.size(), false);
|
|
||||||
else
|
|
||||||
mergeItemStack(stack, 0, 15, false);
|
|
||||||
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
|
||||||
|
|
||||||
import static com.simibubi.create.foundation.gui.ScreenResources.FLEXCRATE;
|
|
||||||
import static com.simibubi.create.foundation.gui.ScreenResources.PLAYER_INVENTORY;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.simibubi.create.AllBlocks;
|
|
||||||
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
|
||||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
|
||||||
import com.simibubi.create.foundation.gui.ScreenResources;
|
|
||||||
import com.simibubi.create.foundation.gui.widgets.Label;
|
|
||||||
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
|
|
||||||
public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContainer> {
|
|
||||||
|
|
||||||
private FlexcrateTileEntity te;
|
|
||||||
private Label allowedItemsLabel;
|
|
||||||
private ScrollInput allowedItems;
|
|
||||||
private int lastModification;
|
|
||||||
|
|
||||||
public FlexcrateScreen(FlexcrateContainer container, PlayerInventory inv, ITextComponent title) {
|
|
||||||
super(container, inv, title);
|
|
||||||
te = container.te;
|
|
||||||
lastModification = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
setWindowSize(PLAYER_INVENTORY.width + 100, FLEXCRATE.height + PLAYER_INVENTORY.height + 20);
|
|
||||||
super.init();
|
|
||||||
widgets.clear();
|
|
||||||
|
|
||||||
allowedItemsLabel = new Label(guiLeft + 100 + 70, guiTop + 107, "").colored(0xD3CBBE).withShadow();
|
|
||||||
allowedItems = new ScrollInput(guiLeft + 100 + 65, guiTop + 104, 41, 14).titled("Storage Space")
|
|
||||||
.withRange(1, 1025).writingTo(allowedItemsLabel).withShiftStep(64).setState(te.allowedAmount)
|
|
||||||
.calling(s -> lastModification = 0);
|
|
||||||
allowedItems.onChanged();
|
|
||||||
widgets.add(allowedItemsLabel);
|
|
||||||
widgets.add(allowedItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
int crateLeft = guiLeft + 100;
|
|
||||||
int crateTop = guiTop;
|
|
||||||
int invLeft = guiLeft + 50;
|
|
||||||
int invTop = crateTop + FLEXCRATE.height + 10;
|
|
||||||
int hFontColor = 0xD3CBBE;
|
|
||||||
int fontColor = 0x4B3A22;
|
|
||||||
|
|
||||||
FLEXCRATE.draw(this, crateLeft, crateTop);
|
|
||||||
font.drawStringWithShadow("FlexCrate", crateLeft - 3 + (FLEXCRATE.width - font.getStringWidth("FlexCrate")) / 2,
|
|
||||||
crateTop + 10, hFontColor);
|
|
||||||
String itemCount = "" + te.itemCount;
|
|
||||||
font.drawString(itemCount, crateLeft + 53 - font.getStringWidth(itemCount), crateTop + 107, fontColor);
|
|
||||||
|
|
||||||
PLAYER_INVENTORY.draw(this, invLeft, invTop);
|
|
||||||
font.drawString("Inventory", invLeft + 7, invTop + 6, 0x666666);
|
|
||||||
|
|
||||||
for (int slot = 0; slot < 16; slot++) {
|
|
||||||
if (allowedItems.getState() > slot * 64)
|
|
||||||
continue;
|
|
||||||
int x = crateLeft + 23 + (slot % 4) * 18;
|
|
||||||
int y = crateTop + 24 + (slot / 4) * 18;
|
|
||||||
ScreenResources.FLEXCRATE_LOCKED_SLOT.draw(this, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
super.tick();
|
|
||||||
if (lastModification >= 0)
|
|
||||||
lastModification++;
|
|
||||||
|
|
||||||
if (lastModification >= 15) {
|
|
||||||
lastModification = -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockState getRenderedBlock() {
|
|
||||||
GlStateManager.translated(guiLeft + FLEXCRATE.width + 145, guiTop + 115, 0);
|
|
||||||
GlStateManager.rotatef(50, -.5f, 1, -.2f);
|
|
||||||
return AllBlocks.FLEXCRATE.get().getDefaultState();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
|
||||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.inventory.container.Container;
|
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
|
||||||
|
|
||||||
public class FlexcrateTileEntity extends SyncedTileEntity implements INamedContainerProvider {
|
|
||||||
|
|
||||||
public class Inv extends ItemStackHandler {
|
|
||||||
public Inv() {
|
|
||||||
super(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSlotLimit(int slot) {
|
|
||||||
if (slot < allowedAmount / 64)
|
|
||||||
return super.getSlotLimit(slot);
|
|
||||||
else if (slot == allowedAmount / 64)
|
|
||||||
return allowedAmount % 64;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValid(int slot, ItemStack stack) {
|
|
||||||
if (slot > allowedAmount / 64)
|
|
||||||
return false;
|
|
||||||
return super.isItemValid(slot, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onContentsChanged(int slot) {
|
|
||||||
super.onContentsChanged(slot);
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Inv inventory;
|
|
||||||
public int allowedAmount;
|
|
||||||
public int itemCount;
|
|
||||||
|
|
||||||
public FlexcrateTileEntity() {
|
|
||||||
this(AllTileEntities.FLEXCRATE.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlexcrateTileEntity(TileEntityType<?> type) {
|
|
||||||
super(type);
|
|
||||||
allowedAmount = 512;
|
|
||||||
itemCount = 10;
|
|
||||||
inventory = new Inv();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
|
|
||||||
return new FlexcrateContainer(id, inventory, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT write(CompoundNBT compound) {
|
|
||||||
compound.putInt("AllowedAmount", allowedAmount);
|
|
||||||
compound.put("Inventory", inventory.serializeNBT());
|
|
||||||
return super.write(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(CompoundNBT compound) {
|
|
||||||
allowedAmount = compound.getInt("AllowedAmount");
|
|
||||||
inventory.deserializeNBT(compound.getCompound("Inventory"));
|
|
||||||
super.read(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITextComponent getDisplayName() {
|
|
||||||
return new StringTextComponent(getType().getRegistryName().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendToContainer(PacketBuffer buffer) {
|
|
||||||
buffer.writeBlockPos(getPos());
|
|
||||||
buffer.writeCompoundTag(getUpdateTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction facing) {
|
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
|
||||||
return LazyOptional.of(() -> inventory).cast();
|
|
||||||
}
|
|
||||||
return super.getCapability(capability, facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
package com.simibubi.create.modules.logistics;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import com.simibubi.create.Create;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
|
@EventBusSubscriber
|
||||||
|
public class FrequencyHandler {
|
||||||
|
|
||||||
|
public static final int RANGE = 128;
|
||||||
|
|
||||||
|
static Map<IWorld, Map<Pair<Frequency, Frequency>, List<IHaveWireless>>> connections = new HashMap<>();
|
||||||
|
|
||||||
|
public static class Frequency {
|
||||||
|
private ItemStack stack;
|
||||||
|
private Item item;
|
||||||
|
private int color;
|
||||||
|
|
||||||
|
public Frequency(ItemStack stack) {
|
||||||
|
this.stack = stack;
|
||||||
|
item = stack.getItem();
|
||||||
|
CompoundNBT displayTag = stack.getChildTag("display");
|
||||||
|
color = displayTag != null && displayTag.contains("color") ? displayTag.getInt("color") : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return item.hashCode() ^ color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj instanceof Frequency ? ((Frequency) obj).item == item && ((Frequency) obj).color == color
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onLoadWorld(WorldEvent.Load event) {
|
||||||
|
connections.put(event.getWorld(), new HashMap<>());
|
||||||
|
Create.logger.info("Prepared network space for " + event.getWorld().getDimension().getType().getRegistryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onUnloadWorld(WorldEvent.Unload event) {
|
||||||
|
connections.remove(event.getWorld());
|
||||||
|
Create.logger.info("Removed network space for " + event.getWorld().getDimension().getType().getRegistryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pair<Frequency, Frequency> getNetworkKey(IHaveWireless actor) {
|
||||||
|
return Pair.of(actor.getFrequencyFirst(), actor.getFrequencyLast());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<IHaveWireless> getNetworkOf(IHaveWireless actor) {
|
||||||
|
Map<Pair<Frequency, Frequency>, List<IHaveWireless>> networksInWorld = networksIn(actor.getWorld());
|
||||||
|
Pair<Frequency, Frequency> key = getNetworkKey(actor);
|
||||||
|
if (!networksInWorld.containsKey(key))
|
||||||
|
networksInWorld.put(key, new ArrayList<>());
|
||||||
|
return networksInWorld.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addToNetwork(IHaveWireless actor) {
|
||||||
|
getNetworkOf(actor).add(actor);
|
||||||
|
updateNetworkOf(actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeFromNetwork(IHaveWireless actor) {
|
||||||
|
List<IHaveWireless> network = getNetworkOf(actor);
|
||||||
|
network.remove(actor);
|
||||||
|
if (network.isEmpty()) {
|
||||||
|
networksIn(actor.getWorld()).remove(getNetworkKey(actor));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateNetworkOf(actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateNetworkOf(IHaveWireless actor) {
|
||||||
|
List<IHaveWireless> network = getNetworkOf(actor);
|
||||||
|
boolean powered = false;
|
||||||
|
|
||||||
|
// Update from Transmitters
|
||||||
|
for (IHaveWireless other : network) {
|
||||||
|
if (!other.isLoaded() || !withinRange(actor, other))
|
||||||
|
continue;
|
||||||
|
if (other instanceof ITransmitWireless && ((ITransmitWireless) other).getSignal()) {
|
||||||
|
powered = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the Receivers
|
||||||
|
for (IHaveWireless other : network) {
|
||||||
|
if (!other.isLoaded() || !withinRange(actor, other))
|
||||||
|
continue;
|
||||||
|
if (other instanceof IReceiveWireless)
|
||||||
|
((IReceiveWireless) other).setSignal(powered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean withinRange(IHaveWireless from, IHaveWireless to) {
|
||||||
|
return from.getPos().withinDistance(to.getPos(), RANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Pair<Frequency, Frequency>, List<IHaveWireless>> networksIn(IWorld world) {
|
||||||
|
if (!connections.containsKey(world)) {
|
||||||
|
Create.logger.warn(
|
||||||
|
"Tried to Access unprepared network space of " + world.getDimension().getType().getRegistryName());
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
return connections.get(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.simibubi.create.modules.logistics;
|
||||||
|
|
||||||
|
import com.simibubi.create.modules.logistics.FrequencyHandler.Frequency;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public interface IHaveWireless {
|
||||||
|
|
||||||
|
public Frequency getFrequencyFirst();
|
||||||
|
public Frequency getFrequencyLast();
|
||||||
|
public World getWorld();
|
||||||
|
public BlockPos getPos();
|
||||||
|
|
||||||
|
public default boolean isLoaded() {
|
||||||
|
return getWorld().isBlockPresent(getPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.simibubi.create.modules.logistics;
|
||||||
|
|
||||||
|
public interface IReceiveWireless extends IHaveWireless {
|
||||||
|
|
||||||
|
public void setSignal(boolean powered);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.simibubi.create.modules.logistics;
|
||||||
|
|
||||||
|
public interface ITransmitWireless extends IHaveWireless {
|
||||||
|
|
||||||
|
public boolean getSignal();
|
||||||
|
public default void notifySignalChange() {
|
||||||
|
FrequencyHandler.updateNetworkOf(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,199 +0,0 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.POWERED;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
|
||||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public class RedstoneBridgeTileEntity extends SyncedTileEntity implements ITickableTileEntity {
|
|
||||||
|
|
||||||
public static final int RANGE = 128;
|
|
||||||
|
|
||||||
static Map<Pair<Frequency, Frequency>, List<RedstoneBridgeTileEntity>> connections;
|
|
||||||
|
|
||||||
public static class Frequency {
|
|
||||||
private ItemStack stack;
|
|
||||||
private Item item;
|
|
||||||
private int color;
|
|
||||||
|
|
||||||
public Frequency(ItemStack stack) {
|
|
||||||
this.stack = stack;
|
|
||||||
item = stack.getItem();
|
|
||||||
CompoundNBT displayTag = stack.getChildTag("display");
|
|
||||||
color = displayTag != null && displayTag.contains("color") ? displayTag.getInt("color") : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getStack() {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return item.hashCode() ^ color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
return obj instanceof Frequency ? ((Frequency) obj).item == item && ((Frequency) obj).color == color
|
|
||||||
: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Frequency frequencyFirst;
|
|
||||||
public Frequency frequencyLast;
|
|
||||||
public boolean networkChanged;
|
|
||||||
|
|
||||||
public RedstoneBridgeTileEntity() {
|
|
||||||
super(AllTileEntities.REDSTONE_BRIDGE.type);
|
|
||||||
frequencyFirst = new Frequency(ItemStack.EMPTY);
|
|
||||||
frequencyLast = new Frequency(ItemStack.EMPTY);
|
|
||||||
|
|
||||||
if (connections == null)
|
|
||||||
connections = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
super.onLoad();
|
|
||||||
if (world.isRemote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addToNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
super.remove();
|
|
||||||
if (world.isRemote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
removeFromNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFrequency(boolean first, ItemStack stack) {
|
|
||||||
stack = stack.copy();
|
|
||||||
stack.setCount(1);
|
|
||||||
ItemStack toCompare = first ? frequencyFirst.stack : frequencyLast.stack;
|
|
||||||
boolean changed = !ItemStack.areItemsEqual(stack, toCompare)
|
|
||||||
|| !ItemStack.areItemStackTagsEqual(stack, toCompare);
|
|
||||||
|
|
||||||
if (changed)
|
|
||||||
removeFromNetwork();
|
|
||||||
|
|
||||||
if (first)
|
|
||||||
frequencyFirst = new Frequency(stack);
|
|
||||||
else
|
|
||||||
frequencyLast = new Frequency(stack);
|
|
||||||
|
|
||||||
if (!changed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 18);
|
|
||||||
addToNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Pair<Frequency, Frequency> getNetworkKey() {
|
|
||||||
return Pair.of(frequencyFirst, frequencyLast);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addToNetwork() {
|
|
||||||
Pair<Frequency, Frequency> networkKey = getNetworkKey();
|
|
||||||
List<RedstoneBridgeTileEntity> TEs = connections.getOrDefault(networkKey, new ArrayList<>());
|
|
||||||
TEs.add(this);
|
|
||||||
connections.put(networkKey, TEs);
|
|
||||||
notifyNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void removeFromNetwork() {
|
|
||||||
Pair<Frequency, Frequency> networkKey = getNetworkKey();
|
|
||||||
List<RedstoneBridgeTileEntity> TEs = connections.get(networkKey);
|
|
||||||
if (TEs != null)
|
|
||||||
TEs.remove(this);
|
|
||||||
if (TEs.isEmpty()) {
|
|
||||||
connections.remove(networkKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
notifyNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isNetworkPowered() {
|
|
||||||
List<RedstoneBridgeTileEntity> TEs = connections.get(getNetworkKey());
|
|
||||||
for (RedstoneBridgeTileEntity te : TEs) {
|
|
||||||
if (te == this)
|
|
||||||
continue;
|
|
||||||
if (te.canProvideNetworkPower())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void notifyNetwork() {
|
|
||||||
for (RedstoneBridgeTileEntity te : connections.get(getNetworkKey()))
|
|
||||||
te.networkChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canProvideNetworkPower() {
|
|
||||||
return isBlockPowered() && isTransmitter();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTransmitter() {
|
|
||||||
return !getBlockState().get(RedstoneBridgeBlock.RECEIVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBlockPowered() {
|
|
||||||
return getBlockState().get(POWERED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void blockChanged() {
|
|
||||||
notifyNetwork();
|
|
||||||
networkChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT write(CompoundNBT compound) {
|
|
||||||
compound.put("FrequencyFirst", frequencyFirst.getStack().write(new CompoundNBT()));
|
|
||||||
compound.put("FrequencyLast", frequencyLast.getStack().write(new CompoundNBT()));
|
|
||||||
return super.write(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(CompoundNBT compound) {
|
|
||||||
frequencyFirst = new Frequency(ItemStack.read(compound.getCompound("FrequencyFirst")));
|
|
||||||
frequencyLast = new Frequency(ItemStack.read(compound.getCompound("FrequencyLast")));
|
|
||||||
super.read(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
if (!networkChanged)
|
|
||||||
return;
|
|
||||||
networkChanged = false;
|
|
||||||
|
|
||||||
if (isTransmitter())
|
|
||||||
return;
|
|
||||||
if (isNetworkPowered() != isBlockPowered()) {
|
|
||||||
world.setBlockState(pos, getBlockState().cycle(POWERED));
|
|
||||||
Direction attachedFace = getBlockState().get(BlockStateProperties.FACING).getOpposite();
|
|
||||||
BlockPos attachedPos = pos.offset(attachedFace);
|
|
||||||
world.notifyNeighbors(attachedPos, world.getBlockState(attachedPos).getBlock());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
|
||||||
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
|
||||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
|
|
||||||
public class StockswitchTileEntity extends SyncedTileEntity {
|
|
||||||
|
|
||||||
float onWhenAbove;
|
|
||||||
float offWhenBelow;
|
|
||||||
float currentLevel;
|
|
||||||
|
|
||||||
public StockswitchTileEntity() {
|
|
||||||
this(AllTileEntities.STOCKSWITCH.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public StockswitchTileEntity(TileEntityType<?> typeIn) {
|
|
||||||
super(typeIn);
|
|
||||||
onWhenAbove = .75f;
|
|
||||||
offWhenBelow = .25f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(CompoundNBT compound) {
|
|
||||||
|
|
||||||
onWhenAbove = compound.getFloat("OnAbove");
|
|
||||||
offWhenBelow = compound.getFloat("OffBelow");
|
|
||||||
updateCurrentLevel();
|
|
||||||
|
|
||||||
super.read(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT write(CompoundNBT compound) {
|
|
||||||
|
|
||||||
compound.putFloat("OnAbove", onWhenAbove);
|
|
||||||
compound.putFloat("OffBelow", offWhenBelow);
|
|
||||||
|
|
||||||
return super.write(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCurrentLevel() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.HorizontalBlock;
|
||||||
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.state.BooleanProperty;
|
||||||
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ExtractorBlock extends HorizontalBlock {
|
||||||
|
|
||||||
|
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||||
|
public static final VoxelShape SHAPE_NORTH = makeCuboidShape(4, 2, -1, 12, 10, 5),
|
||||||
|
SHAPE_SOUTH = makeCuboidShape(4, 2, 11, 12, 10, 17), SHAPE_WEST = makeCuboidShape(-1, 2, 4, 5, 10, 12),
|
||||||
|
SHAPE_EAST = makeCuboidShape(11, 2, 4, 17, 10, 12);
|
||||||
|
|
||||||
|
public ExtractorBlock() {
|
||||||
|
super(Properties.from(Blocks.ANDESITE));
|
||||||
|
setDefaultState(getDefaultState().with(POWERED, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(HORIZONTAL_FACING, POWERED);
|
||||||
|
super.fillStateContainer(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
BlockState state = getDefaultState();
|
||||||
|
|
||||||
|
if (context.getFace().getAxis().isHorizontal()) {
|
||||||
|
state = state.with(HORIZONTAL_FACING, context.getFace().getOpposite());
|
||||||
|
} else {
|
||||||
|
state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing());
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.with(POWERED, Boolean.valueOf(context.getWorld().isBlockPowered(context.getPos())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||||
|
boolean isMoving) {
|
||||||
|
if (worldIn.isRemote)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean previouslyPowered = state.get(POWERED);
|
||||||
|
if (previouslyPowered != worldIn.isBlockPowered(pos)) {
|
||||||
|
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
|
Direction facing = state.get(HORIZONTAL_FACING);
|
||||||
|
|
||||||
|
if (facing == Direction.EAST)
|
||||||
|
return SHAPE_EAST;
|
||||||
|
if (facing == Direction.WEST)
|
||||||
|
return SHAPE_WEST;
|
||||||
|
if (facing == Direction.SOUTH)
|
||||||
|
return SHAPE_SOUTH;
|
||||||
|
if (facing == Direction.NORTH)
|
||||||
|
return SHAPE_NORTH;
|
||||||
|
|
||||||
|
return VoxelShapes.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.InfoBlock;
|
import com.simibubi.create.foundation.block.InfoBlock;
|
||||||
import com.simibubi.create.foundation.utility.ItemDescription;
|
import com.simibubi.create.foundation.utility.ItemDescription;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import com.simibubi.create.AllContainers;
|
import com.simibubi.create.AllContainers;
|
||||||
|
|
||||||
|
@ -63,8 +63,10 @@ public class FlexcrateContainer extends Container {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
ItemStack stack = clickedSlot.getStack();
|
ItemStack stack = clickedSlot.getStack();
|
||||||
if (index < 16)
|
if (index < 16) {
|
||||||
mergeItemStack(stack, 16, inventorySlots.size(), false);
|
mergeItemStack(stack, 16, inventorySlots.size(), false);
|
||||||
|
te.inventory.onContentsChanged(index);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mergeItemStack(stack, 0, 15, false);
|
mergeItemStack(stack, 0, 15, false);
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import static com.simibubi.create.foundation.gui.ScreenResources.FLEXCRATE;
|
import static com.simibubi.create.foundation.gui.ScreenResources.FLEXCRATE;
|
||||||
import static com.simibubi.create.foundation.gui.ScreenResources.PLAYER_INVENTORY;
|
import static com.simibubi.create.foundation.gui.ScreenResources.PLAYER_INVENTORY;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.AllPackets;
|
||||||
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
||||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||||
import com.simibubi.create.foundation.gui.ScreenResources;
|
import com.simibubi.create.foundation.gui.ScreenResources;
|
||||||
import com.simibubi.create.foundation.gui.widgets.Label;
|
import com.simibubi.create.foundation.gui.widgets.Label;
|
||||||
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
||||||
|
import com.simibubi.create.modules.logistics.packet.ConfigureFlexcratePacket;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
@ -71,16 +73,21 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
|
||||||
|
|
||||||
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removed() {
|
||||||
|
AllPackets.channel.sendToServer(new ConfigureFlexcratePacket(te.getPos(), allowedItems.getState()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (lastModification >= 0)
|
if (lastModification >= 0)
|
||||||
lastModification++;
|
lastModification++;
|
||||||
|
|
||||||
if (lastModification >= 15) {
|
if (lastModification >= 15) {
|
||||||
lastModification = -1;
|
lastModification = -1;
|
||||||
|
AllPackets.channel.sendToServer(new ConfigureFlexcratePacket(te.getPos(), allowedItems.getState()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||||
|
@ -17,6 +17,7 @@ import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
public class FlexcrateTileEntity extends SyncedTileEntity implements INamedContainerProvider {
|
public class FlexcrateTileEntity extends SyncedTileEntity implements INamedContainerProvider {
|
||||||
|
@ -46,12 +47,18 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
|
||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
|
itemCount = 0;
|
||||||
|
for (int i = 0; i < getSlots(); i++) {
|
||||||
|
itemCount += getStackInSlot(i).getCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inv inventory;
|
public Inv inventory;
|
||||||
public int allowedAmount;
|
public int allowedAmount;
|
||||||
public int itemCount;
|
public int itemCount;
|
||||||
|
protected LazyOptional<IItemHandler> invHandler;
|
||||||
|
|
||||||
public FlexcrateTileEntity() {
|
public FlexcrateTileEntity() {
|
||||||
this(AllTileEntities.FLEXCRATE.type);
|
this(AllTileEntities.FLEXCRATE.type);
|
||||||
|
@ -62,6 +69,7 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
|
||||||
allowedAmount = 512;
|
allowedAmount = 512;
|
||||||
itemCount = 10;
|
itemCount = 10;
|
||||||
inventory = new Inv();
|
inventory = new Inv();
|
||||||
|
invHandler = LazyOptional.of(() -> inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,11 +101,16 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
|
||||||
buffer.writeCompoundTag(getUpdateTag());
|
buffer.writeCompoundTag(getUpdateTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
super.remove();
|
||||||
|
invHandler.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction facing) {
|
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction facing) {
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||||
return LazyOptional.of(() -> inventory).cast();
|
return invHandler.cast();
|
||||||
}
|
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class LinkedExtractorBlock extends ExtractorBlock {
|
||||||
|
|
||||||
|
public LinkedExtractorBlock() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockRenderLayer getRenderLayer() {
|
||||||
|
return BlockRenderLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
return super.getStateForPlacement(context).with(POWERED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||||
|
boolean isMoving) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,7 +42,6 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorld;
|
|
||||||
import net.minecraft.world.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -61,10 +60,8 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements ITool
|
||||||
public static final VoxelShape UP_SHAPE = makeCuboidShape(2, 0, 2, 14, 3, 14),
|
public static final VoxelShape UP_SHAPE = makeCuboidShape(2, 0, 2, 14, 3, 14),
|
||||||
DOWN_SHAPE = makeCuboidShape(2, 13, 2, 14, 16, 14);
|
DOWN_SHAPE = makeCuboidShape(2, 13, 2, 14, 16, 14);
|
||||||
|
|
||||||
public static final VoxelShape
|
public static final VoxelShape SOUTH_SHAPE = makeCuboidShape(3, 1, -1, 13, 15, 3),
|
||||||
SOUTH_SHAPE = makeCuboidShape(3, 1, -1, 13, 15, 3),
|
NORTH_SHAPE = makeCuboidShape(3, 1, 13, 13, 15, 17), EAST_SHAPE = makeCuboidShape(-1, 1, 3, 3, 15, 13),
|
||||||
NORTH_SHAPE = makeCuboidShape(3, 1, 13, 13, 15, 17),
|
|
||||||
EAST_SHAPE = makeCuboidShape(-1, 1, 3, 3, 15, 13),
|
|
||||||
WEST_SHAPE = makeCuboidShape(13, 1, 3, 17, 15, 13);
|
WEST_SHAPE = makeCuboidShape(13, 1, 3, 17, 15, 13);
|
||||||
|
|
||||||
private TooltipHolder info;
|
private TooltipHolder info;
|
||||||
|
@ -88,47 +85,34 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements ITool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTransmittedSignal(state, worldIn, pos, blockFacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||||
|
updateTransmittedSignal(state, worldIn, pos, state.get(FACING));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTransmittedSignal(BlockState state, World worldIn, BlockPos pos, Direction blockFacing) {
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return;
|
return;
|
||||||
if (state.get(RECEIVER))
|
if (state.get(RECEIVER))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
boolean shouldPower = worldIn.getWorld().isBlockPowered(pos.offset(blockFacing.getOpposite()))
|
||||||
|
|| worldIn.getWorld().isBlockPowered(pos);
|
||||||
boolean previouslyPowered = state.get(POWERED);
|
boolean previouslyPowered = state.get(POWERED);
|
||||||
if (previouslyPowered != worldIn.isBlockPowered(pos.offset(blockFacing.getOpposite()))) {
|
|
||||||
|
if (previouslyPowered != shouldPower) {
|
||||||
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
||||||
|
|
||||||
RedstoneBridgeTileEntity te = (RedstoneBridgeTileEntity) worldIn.getTileEntity(pos);
|
RedstoneBridgeTileEntity te = (RedstoneBridgeTileEntity) worldIn.getTileEntity(pos);
|
||||||
if (te == null)
|
if (te == null)
|
||||||
return;
|
return;
|
||||||
te.blockChanged();
|
te.transmit(!previouslyPowered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn,
|
|
||||||
BlockPos currentPos, BlockPos facingPos) {
|
|
||||||
boolean shouldPower = false;
|
|
||||||
Direction blockFacing = stateIn.get(FACING);
|
|
||||||
|
|
||||||
if (worldIn.getWorld().isRemote)
|
|
||||||
return stateIn;
|
|
||||||
if (stateIn.get(RECEIVER))
|
|
||||||
return stateIn;
|
|
||||||
|
|
||||||
shouldPower = worldIn.getWorld().isBlockPowered(currentPos.offset(blockFacing.getOpposite()))
|
|
||||||
|| worldIn.getWorld().isBlockPowered(currentPos);
|
|
||||||
if (stateIn.get(POWERED) != shouldPower) {
|
|
||||||
|
|
||||||
RedstoneBridgeTileEntity te = (RedstoneBridgeTileEntity) worldIn.getTileEntity(currentPos);
|
|
||||||
if (te == null)
|
|
||||||
return stateIn;
|
|
||||||
te.blockChanged();
|
|
||||||
|
|
||||||
return stateIn.with(POWERED, shouldPower);
|
|
||||||
}
|
|
||||||
return stateIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvidePower(BlockState state) {
|
public boolean canProvidePower(BlockState state) {
|
||||||
return state.get(POWERED) && state.get(RECEIVER);
|
return state.get(POWERED) && state.get(RECEIVER);
|
||||||
|
@ -177,8 +161,13 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements ITool
|
||||||
|
|
||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
worldIn.setBlockState(pos, state.cycle(RECEIVER));
|
Boolean wasReceiver = state.get(RECEIVER);
|
||||||
te.blockChanged();
|
boolean blockPowered = worldIn.isBlockPowered(pos);
|
||||||
|
worldIn.setBlockState(pos, state.cycle(RECEIVER).with(POWERED, blockPowered), 3);
|
||||||
|
if (wasReceiver) {
|
||||||
|
te.transmit(worldIn.isBlockPowered(pos));
|
||||||
|
} else
|
||||||
|
te.transmit(false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
|
import static net.minecraft.state.properties.BlockStateProperties.POWERED;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllTileEntities;
|
||||||
|
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||||
|
import com.simibubi.create.modules.logistics.FrequencyHandler;
|
||||||
|
import com.simibubi.create.modules.logistics.FrequencyHandler.Frequency;
|
||||||
|
import com.simibubi.create.modules.logistics.IReceiveWireless;
|
||||||
|
import com.simibubi.create.modules.logistics.ITransmitWireless;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class RedstoneBridgeTileEntity extends SyncedTileEntity
|
||||||
|
implements ITickableTileEntity, IReceiveWireless, ITransmitWireless {
|
||||||
|
|
||||||
|
public Frequency frequencyFirst;
|
||||||
|
public Frequency frequencyLast;
|
||||||
|
public boolean receivedSignal;
|
||||||
|
public boolean transmittedSignal;
|
||||||
|
|
||||||
|
public RedstoneBridgeTileEntity() {
|
||||||
|
super(AllTileEntities.REDSTONE_BRIDGE.type);
|
||||||
|
frequencyFirst = new Frequency(ItemStack.EMPTY);
|
||||||
|
frequencyLast = new Frequency(ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
super.onLoad();
|
||||||
|
if (world.isRemote)
|
||||||
|
return;
|
||||||
|
FrequencyHandler.addToNetwork(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
super.remove();
|
||||||
|
if (world.isRemote)
|
||||||
|
return;
|
||||||
|
FrequencyHandler.removeFromNetwork(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequency(boolean first, ItemStack stack) {
|
||||||
|
stack = stack.copy();
|
||||||
|
stack.setCount(1);
|
||||||
|
ItemStack toCompare = first ? frequencyFirst.getStack() : frequencyLast.getStack();
|
||||||
|
boolean changed = !ItemStack.areItemsEqual(stack, toCompare)
|
||||||
|
|| !ItemStack.areItemStackTagsEqual(stack, toCompare);
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
FrequencyHandler.removeFromNetwork(this);
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
frequencyFirst = new Frequency(stack);
|
||||||
|
else
|
||||||
|
frequencyLast = new Frequency(stack);
|
||||||
|
|
||||||
|
if (!changed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sendData();
|
||||||
|
FrequencyHandler.addToNetwork(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Frequency getFrequencyFirst() {
|
||||||
|
return frequencyFirst;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Frequency getFrequencyLast() {
|
||||||
|
return frequencyLast;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSignal() {
|
||||||
|
return transmittedSignal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transmit(boolean signal) {
|
||||||
|
transmittedSignal = signal;
|
||||||
|
notifySignalChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSignal(boolean powered) {
|
||||||
|
receivedSignal = powered;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isTransmitter() {
|
||||||
|
return !getBlockState().get(RedstoneBridgeBlock.RECEIVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isBlockPowered() {
|
||||||
|
return getBlockState().get(POWERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
|
compound.put("FrequencyFirst", frequencyFirst.getStack().write(new CompoundNBT()));
|
||||||
|
compound.put("FrequencyLast", frequencyLast.getStack().write(new CompoundNBT()));
|
||||||
|
compound.putBoolean("Transmit", transmittedSignal);
|
||||||
|
return super.write(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(CompoundNBT compound) {
|
||||||
|
frequencyFirst = new Frequency(ItemStack.read(compound.getCompound("FrequencyFirst")));
|
||||||
|
frequencyLast = new Frequency(ItemStack.read(compound.getCompound("FrequencyLast")));
|
||||||
|
transmittedSignal = compound.getBoolean("Transmit");
|
||||||
|
super.read(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
if (isTransmitter())
|
||||||
|
return;
|
||||||
|
if (world.isRemote)
|
||||||
|
return;
|
||||||
|
if (receivedSignal != isBlockPowered()) {
|
||||||
|
world.setBlockState(pos, getBlockState().cycle(POWERED));
|
||||||
|
Direction attachedFace = getBlockState().get(BlockStateProperties.FACING).getOpposite();
|
||||||
|
BlockPos attachedPos = pos.offset(attachedFace);
|
||||||
|
world.notifyNeighbors(attachedPos, world.getBlockState(attachedPos).getBlock());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -19,11 +19,13 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.IntegerProperty;
|
import net.minecraft.state.IntegerProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
import net.minecraft.world.IWorldReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
@ -43,6 +45,47 @@ public class StockswitchBlock extends HorizontalBlock implements ITooltip {
|
||||||
public boolean isSolid(BlockState state) {
|
public boolean isSolid(BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||||
|
updateObservedInventory(state, worldIn, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
|
||||||
|
if (world.isRemote())
|
||||||
|
return;
|
||||||
|
if (!isObserving(state, pos, neighbor))
|
||||||
|
return;
|
||||||
|
updateObservedInventory(state, world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) {
|
||||||
|
StockswitchTileEntity te = (StockswitchTileEntity) world.getTileEntity(pos);
|
||||||
|
if (te == null)
|
||||||
|
return;
|
||||||
|
te.updateCurrentLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) {
|
||||||
|
return observing.equals(pos.offset(state.get(HORIZONTAL_FACING)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
|
||||||
|
return side != null && side.getOpposite() != state.get(HORIZONTAL_FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvidePower(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
|
||||||
|
StockswitchTileEntity te = (StockswitchTileEntity) blockAccess.getTileEntity(pos);
|
||||||
|
return te == null || !te.powered ? 0 : 15 ;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip,
|
public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip,
|
|
@ -1,4 +1,4 @@
|
||||||
package com.simibubi.create.modules.logistics;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import static com.simibubi.create.foundation.gui.ScreenResources.STOCKSWITCH;
|
import static com.simibubi.create.foundation.gui.ScreenResources.STOCKSWITCH;
|
||||||
|
|
||||||
|
@ -6,11 +6,13 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.AllPackets;
|
||||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||||
import com.simibubi.create.foundation.gui.ScreenResources;
|
import com.simibubi.create.foundation.gui.ScreenResources;
|
||||||
import com.simibubi.create.foundation.gui.widgets.Label;
|
import com.simibubi.create.foundation.gui.widgets.Label;
|
||||||
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
|
||||||
|
import com.simibubi.create.modules.logistics.packet.ConfigureStockswitchPacket;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
|
@ -21,10 +23,13 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
||||||
private ScrollInput onAbove;
|
private ScrollInput onAbove;
|
||||||
private Label onAboveLabel;
|
private Label onAboveLabel;
|
||||||
|
|
||||||
|
private int lastModification;
|
||||||
private StockswitchTileEntity te;
|
private StockswitchTileEntity te;
|
||||||
|
private float cursorPos;
|
||||||
|
|
||||||
public StockswitchScreen(StockswitchTileEntity te) {
|
public StockswitchScreen(StockswitchTileEntity te) {
|
||||||
this.te = te;
|
this.te = te;
|
||||||
|
lastModification = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,11 +37,13 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
||||||
setWindowSize(STOCKSWITCH.width + 50, STOCKSWITCH.height);
|
setWindowSize(STOCKSWITCH.width + 50, STOCKSWITCH.height);
|
||||||
super.init();
|
super.init();
|
||||||
widgets.clear();
|
widgets.clear();
|
||||||
|
cursorPos = te.currentLevel == -1 ? 0 : te.currentLevel;
|
||||||
|
|
||||||
offBelowLabel = new Label(guiLeft + 116, guiTop + 72, "").colored(0xD3CBBE).withShadow();
|
offBelowLabel = new Label(guiLeft + 116, guiTop + 72, "").colored(0xD3CBBE).withShadow();
|
||||||
offBelow = new ScrollInput(guiLeft + 113, guiTop + 69, 33, 14).withRange(0, 96).titled("Lower Threshold")
|
offBelow = new ScrollInput(guiLeft + 113, guiTop + 69, 33, 14).withRange(0, 96).titled("Lower Threshold")
|
||||||
.calling(state -> {
|
.calling(state -> {
|
||||||
offBelowLabel.text = state + "%";
|
offBelowLabel.text = state + "%";
|
||||||
|
lastModification = 0;
|
||||||
if (onAbove.getState() - 4 <= state) {
|
if (onAbove.getState() - 4 <= state) {
|
||||||
onAbove.setState(state + 5);
|
onAbove.setState(state + 5);
|
||||||
onAbove.onChanged();
|
onAbove.onChanged();
|
||||||
|
@ -47,6 +54,7 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
||||||
onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101).titled("Upper Threshold")
|
onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101).titled("Upper Threshold")
|
||||||
.calling(state -> {
|
.calling(state -> {
|
||||||
onAboveLabel.text = state + "%";
|
onAboveLabel.text = state + "%";
|
||||||
|
lastModification = 0;
|
||||||
if (offBelow.getState() + 4 >= state) {
|
if (offBelow.getState() + 4 >= state) {
|
||||||
offBelow.setState(state - 5);
|
offBelow.setState(state - 5);
|
||||||
offBelow.onChanged();
|
offBelow.onChanged();
|
||||||
|
@ -74,7 +82,6 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
||||||
ScreenResources sprite = ScreenResources.STOCKSWITCH_INTERVAL;
|
ScreenResources sprite = ScreenResources.STOCKSWITCH_INTERVAL;
|
||||||
float lowerBound = offBelow.getState() / 100f * (sprite.width - 20) + 10;
|
float lowerBound = offBelow.getState() / 100f * (sprite.width - 20) + 10;
|
||||||
float upperBound = onAbove.getState() / 100f * (sprite.width - 20) + 10;
|
float upperBound = onAbove.getState() / 100f * (sprite.width - 20) + 10;
|
||||||
float cursorPos = te.currentLevel * (sprite.width - 20) + 10;
|
|
||||||
|
|
||||||
sprite.bind();
|
sprite.bind();
|
||||||
blit((int) (guiLeft + lowerBound), guiTop + 26, (int) (sprite.startX + lowerBound), sprite.startY,
|
blit((int) (guiLeft + lowerBound), guiTop + 26, (int) (sprite.startX + lowerBound), sprite.startY,
|
||||||
|
@ -88,13 +95,41 @@ public class StockswitchScreen extends AbstractSimiScreen {
|
||||||
ScreenResources.STOCKSWITCH_BOUND_LEFT.draw(this, (int) (guiLeft + lowerBound) - 1, guiTop + 24);
|
ScreenResources.STOCKSWITCH_BOUND_LEFT.draw(this, (int) (guiLeft + lowerBound) - 1, guiTop + 24);
|
||||||
ScreenResources.STOCKSWITCH_BOUND_RIGHT.draw(this, (int) (guiLeft + upperBound) - 5, guiTop + 24);
|
ScreenResources.STOCKSWITCH_BOUND_RIGHT.draw(this, (int) (guiLeft + upperBound) - 5, guiTop + 24);
|
||||||
|
|
||||||
ScreenResources cursor = te.getWorld().isBlockPowered(te.getPos()) ? ScreenResources.STOCKSWITCH_CURSOR_ON
|
ScreenResources cursor = te.powered ? ScreenResources.STOCKSWITCH_CURSOR_ON
|
||||||
: ScreenResources.STOCKSWITCH_CURSOR_OFF;
|
: ScreenResources.STOCKSWITCH_CURSOR_OFF;
|
||||||
cursor.draw(this, (int) (guiLeft + cursorPos), guiTop + 24);
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.translatef((cursorPos * (sprite.width - 20) + 10), 0, 0);
|
||||||
|
cursor.draw(this, guiLeft - 4, guiTop + 24);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
|
||||||
|
if (te.currentLevel == -1)
|
||||||
|
cursorPos = 0;
|
||||||
|
else
|
||||||
|
cursorPos += (te.currentLevel - cursorPos) / 4;
|
||||||
|
|
||||||
|
if (lastModification >= 0)
|
||||||
|
lastModification++;
|
||||||
|
|
||||||
|
if (lastModification >= 20) {
|
||||||
|
lastModification = -1;
|
||||||
|
AllPackets.channel.sendToServer(
|
||||||
|
new ConfigureStockswitchPacket(te.getPos(), offBelow.getState() / 100f, onAbove.getState() / 100f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removed() {
|
||||||
|
AllPackets.channel.sendToServer(
|
||||||
|
new ConfigureStockswitchPacket(te.getPos(), offBelow.getState() / 100f, onAbove.getState() / 100f));
|
||||||
|
}
|
||||||
|
|
||||||
public BlockState getRenderedBlock() {
|
public BlockState getRenderedBlock() {
|
||||||
GlStateManager.translated(guiLeft + STOCKSWITCH.width + 50, guiTop + 100, 0);
|
GlStateManager.translated(guiLeft + STOCKSWITCH.width + 50, guiTop + 100, 0);
|
||||||
GlStateManager.rotatef(50, -.5f, 1, -.2f);
|
GlStateManager.rotatef(50, -.5f, 1, -.2f);
|
|
@ -0,0 +1,130 @@
|
||||||
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllTileEntities;
|
||||||
|
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
public class StockswitchTileEntity extends SyncedTileEntity {
|
||||||
|
|
||||||
|
public float onWhenAbove;
|
||||||
|
public float offWhenBelow;
|
||||||
|
public float currentLevel;
|
||||||
|
public boolean powered;
|
||||||
|
private LazyOptional<IItemHandler> observedInventory;
|
||||||
|
|
||||||
|
public StockswitchTileEntity() {
|
||||||
|
this(AllTileEntities.STOCKSWITCH.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StockswitchTileEntity(TileEntityType<?> typeIn) {
|
||||||
|
super(typeIn);
|
||||||
|
onWhenAbove = .75f;
|
||||||
|
offWhenBelow = .25f;
|
||||||
|
currentLevel = -1;
|
||||||
|
powered = false;
|
||||||
|
observedInventory = LazyOptional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(CompoundNBT compound) {
|
||||||
|
|
||||||
|
onWhenAbove = compound.getFloat("OnAbove");
|
||||||
|
offWhenBelow = compound.getFloat("OffBelow");
|
||||||
|
currentLevel = compound.getFloat("Current");
|
||||||
|
powered = compound.getBoolean("Powered");
|
||||||
|
|
||||||
|
super.read(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
|
|
||||||
|
compound.putFloat("OnAbove", onWhenAbove);
|
||||||
|
compound.putFloat("OffBelow", offWhenBelow);
|
||||||
|
compound.putFloat("Current", currentLevel);
|
||||||
|
compound.putBoolean("Powered", powered);
|
||||||
|
|
||||||
|
return super.write(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getLevel() {
|
||||||
|
return currentLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateCurrentLevel() {
|
||||||
|
if (!observedInventory.isPresent()) {
|
||||||
|
if (!findNewInventory() && currentLevel != -1) {
|
||||||
|
world.setBlockState(pos, getBlockState().with(StockswitchBlock.INDICATOR, 0), 3);
|
||||||
|
currentLevel = -1;
|
||||||
|
powered = false;
|
||||||
|
world.notifyNeighbors(pos, getBlockState().getBlock());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float occupied = 0;
|
||||||
|
float totalSpace = 0;
|
||||||
|
IItemHandler inv = observedInventory.orElse(null);
|
||||||
|
|
||||||
|
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||||
|
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
||||||
|
int space = Math.min(stackInSlot.getMaxStackSize(), inv.getSlotLimit(slot));
|
||||||
|
int count = stackInSlot.getCount();
|
||||||
|
|
||||||
|
if (space == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
totalSpace += 1;
|
||||||
|
occupied += count * (1f / space);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentLevel = (float) occupied / totalSpace;
|
||||||
|
currentLevel = MathHelper.clamp(currentLevel, 0, 1);
|
||||||
|
|
||||||
|
boolean previouslyPowered = powered;
|
||||||
|
if (powered && currentLevel <= offWhenBelow)
|
||||||
|
powered = false;
|
||||||
|
else if (!powered && currentLevel >= onWhenAbove)
|
||||||
|
powered = true;
|
||||||
|
boolean update = previouslyPowered != powered;
|
||||||
|
|
||||||
|
int displayLevel = 0;
|
||||||
|
if (currentLevel > 0)
|
||||||
|
displayLevel = (int) (currentLevel * 6);
|
||||||
|
world.setBlockState(pos, getBlockState().with(StockswitchBlock.INDICATOR, displayLevel), update ? 3 : 2);
|
||||||
|
if (update)
|
||||||
|
world.notifyNeighbors(pos, getBlockState().getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean findNewInventory() {
|
||||||
|
BlockPos invPos = getPos().offset(getBlockState().get(BlockStateProperties.HORIZONTAL_FACING));
|
||||||
|
|
||||||
|
if (!world.isBlockPresent(invPos))
|
||||||
|
return false;
|
||||||
|
BlockState invState = world.getBlockState(invPos);
|
||||||
|
|
||||||
|
if (!invState.hasTileEntity())
|
||||||
|
return false;
|
||||||
|
TileEntity invTE = world.getTileEntity(invPos);
|
||||||
|
|
||||||
|
observedInventory = invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
||||||
|
if (observedInventory.isPresent()) {
|
||||||
|
updateCurrentLevel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.simibubi.create.modules.logistics.item;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.item.InfoItem;
|
||||||
|
import com.simibubi.create.foundation.utility.ItemDescription;
|
||||||
|
import com.simibubi.create.foundation.utility.ItemDescription.Palette;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.color.IItemColor;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class FilterItem extends InfoItem {
|
||||||
|
|
||||||
|
public static class Color implements IItemColor {
|
||||||
|
@Override
|
||||||
|
public int getColor(ItemStack stack, int layer) {
|
||||||
|
if (layer == 0)
|
||||||
|
return 0xFFFFFF;
|
||||||
|
if (layer == 1)
|
||||||
|
return 0x6677AA;
|
||||||
|
if (layer == 2)
|
||||||
|
return 0x334477;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterItem(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemDescription getDescription() {
|
||||||
|
Palette color = Palette.Yellow;
|
||||||
|
return new ItemDescription(color)
|
||||||
|
.withSummary("Holds information for controlling input, output and detection of objects.")
|
||||||
|
.withControl("R-Click while Sneaking", "Opens the " + h("Configuration Screen", color))
|
||||||
|
.withControl("When Entity punched", "Creates a filter with the target set to the Entity.").createTabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.simibubi.create.modules.logistics.packet;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.packet.TileEntityConfigurationPacket;
|
||||||
|
import com.simibubi.create.modules.logistics.block.FlexcrateTileEntity;
|
||||||
|
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class ConfigureFlexcratePacket extends TileEntityConfigurationPacket<FlexcrateTileEntity> {
|
||||||
|
|
||||||
|
private int maxItems;
|
||||||
|
|
||||||
|
public ConfigureFlexcratePacket(PacketBuffer buffer) {
|
||||||
|
super(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigureFlexcratePacket(BlockPos pos, int newMaxItems) {
|
||||||
|
super(pos);
|
||||||
|
this.maxItems = newMaxItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeSettings(PacketBuffer buffer) {
|
||||||
|
buffer.writeInt(maxItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readSettings(PacketBuffer buffer) {
|
||||||
|
maxItems = buffer.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applySettings(FlexcrateTileEntity te) {
|
||||||
|
te.allowedAmount = maxItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.simibubi.create.modules.logistics.packet;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.packet.TileEntityConfigurationPacket;
|
||||||
|
import com.simibubi.create.modules.logistics.block.StockswitchTileEntity;
|
||||||
|
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class ConfigureStockswitchPacket extends TileEntityConfigurationPacket<StockswitchTileEntity> {
|
||||||
|
|
||||||
|
private float offBelow;
|
||||||
|
private float onAbove;
|
||||||
|
|
||||||
|
public ConfigureStockswitchPacket(BlockPos pos, float offBelow, float onAbove) {
|
||||||
|
super(pos);
|
||||||
|
this.offBelow = offBelow;
|
||||||
|
this.onAbove = onAbove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigureStockswitchPacket(PacketBuffer buffer) {
|
||||||
|
super(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readSettings(PacketBuffer buffer) {
|
||||||
|
offBelow = buffer.readFloat();
|
||||||
|
onAbove = buffer.readFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeSettings(PacketBuffer buffer) {
|
||||||
|
buffer.writeFloat(offBelow);
|
||||||
|
buffer.writeFloat(onAbove);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applySettings(StockswitchTileEntity te) {
|
||||||
|
te.offWhenBelow = offBelow;
|
||||||
|
te.onWhenAbove = onAbove;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/main/resources/assets/create/blockstates/extractor.json
Normal file
18
src/main/resources/assets/create/blockstates/extractor.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"forge_marker": 1,
|
||||||
|
"defaults": {
|
||||||
|
"model": "create:block/extractor"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"powered": {
|
||||||
|
"true": { "model": "create:block/extractor_powered" },
|
||||||
|
"false": { "model": "create:block/extractor" }
|
||||||
|
},
|
||||||
|
"facing": {
|
||||||
|
"south": { "y": 180 },
|
||||||
|
"east": { "y": 90 },
|
||||||
|
"north": { "y": 0 },
|
||||||
|
"west": { "y": 270 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"forge_marker": 1,
|
||||||
|
"defaults": {
|
||||||
|
"model": "create:block/extractor_wireless"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"powered": {
|
||||||
|
"true": { "model": "create:block/extractor_wireless_powered" },
|
||||||
|
"false": { "model": "create:block/extractor_wireless" }
|
||||||
|
},
|
||||||
|
"facing": {
|
||||||
|
"south": { "y": 180 },
|
||||||
|
"east": { "y": 90 },
|
||||||
|
"north": { "y": 0 },
|
||||||
|
"west": { "y": 270 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
"item.create.blueprint_and_quill": "Schematic and Quill",
|
"item.create.blueprint_and_quill": "Schematic and Quill",
|
||||||
"item.create.blueprint": "Schematic",
|
"item.create.blueprint": "Schematic",
|
||||||
"item.create.belt_connector": "Mechanical Belt",
|
"item.create.belt_connector": "Mechanical Belt",
|
||||||
|
"item.create.filter": "Filter",
|
||||||
|
|
||||||
"block.create.gear": "Cogwheel",
|
"block.create.gear": "Cogwheel",
|
||||||
"block.create.large_gear": "Large Cogwheel",
|
"block.create.large_gear": "Large Cogwheel",
|
||||||
|
@ -37,6 +38,8 @@
|
||||||
"block.create.redstone_bridge": "Redstone Bridge",
|
"block.create.redstone_bridge": "Redstone Bridge",
|
||||||
"block.create.stockswitch": "Stockpile Switch",
|
"block.create.stockswitch": "Stockpile Switch",
|
||||||
"block.create.flexcrate": "FlexCrate",
|
"block.create.flexcrate": "FlexCrate",
|
||||||
|
"block.create.extractor": "Extractor",
|
||||||
|
"block.create.linked_extractor": "Linked Extractor",
|
||||||
|
|
||||||
"block.create.andesite_bricks": "Andesite Bricks",
|
"block.create.andesite_bricks": "Andesite Bricks",
|
||||||
"block.create.diorite_bricks": "Diorite Bricks",
|
"block.create.diorite_bricks": "Diorite Bricks",
|
||||||
|
|
75
src/main/resources/assets/create/models/block/extractor.json
Normal file
75
src/main/resources/assets/create/models/block/extractor.json
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
{
|
||||||
|
"__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
|
||||||
|
"parent": "block/block",
|
||||||
|
"textures": {
|
||||||
|
"extractor": "create:block/extractor",
|
||||||
|
"particle": "create:block/extractor"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "Bottom",
|
||||||
|
"from": [ 4, 2, -1 ],
|
||||||
|
"to": [ 12, 3, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 6, 7, 14, 8 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ] },
|
||||||
|
"up": { "texture": "#extractor", "uv": [ 9, 0, 15, 8 ], "rotation": 90 },
|
||||||
|
"down": { "texture": "#extractor", "uv": [ 0, 0, 6, 8 ], "rotation": 270 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Top",
|
||||||
|
"from": [ 4, 9, -1 ],
|
||||||
|
"to": [ 12, 10, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 6, 0, 14, 1 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ] },
|
||||||
|
"up": { "texture": "#extractor", "uv": [ 0, 0, 6, 8 ], "rotation": 90 },
|
||||||
|
"down": { "texture": "#extractor", "uv": [ 9, 0, 15, 8 ], "rotation": 270 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Side",
|
||||||
|
"from": [ 4, 3, -1 ],
|
||||||
|
"to": [ 5, 9, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 9, 1, 15, 7 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 6, 1, 7, 7 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0, 1, 6, 7 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Side",
|
||||||
|
"from": [ 11, 3, -1 ],
|
||||||
|
"to": [ 12, 9, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0, 1, 6, 7 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 13, 1, 14, 7 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 9, 1, 15, 7 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Center",
|
||||||
|
"from": [ 5, 3, 3 ],
|
||||||
|
"to": [ 11, 9, 4 ],
|
||||||
|
"faces": {
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 7, 1, 13, 7 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "FilterSpot",
|
||||||
|
"from": [ 5, 10, -0.6 ],
|
||||||
|
"to": [ 11, 12, 4 ],
|
||||||
|
"rotation": { "origin": [ 8, 11, -1 ], "axis": "x", "angle": 22.5 },
|
||||||
|
"faces": {
|
||||||
|
"north": { "texture": "#extractor", "uv": [ 13, 1, 15, 7 ], "rotation": 90 },
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0.1, 0, 4.7, 2 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 4, 1, 5, 7 ], "rotation": 270 },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0.1, 0, 4.7, 2 ] },
|
||||||
|
"up": { "texture": "#extractor", "uv": [ 0, 9, 5, 15 ], "rotation": 90 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"parent": "create:block/extractor",
|
||||||
|
"textures": {
|
||||||
|
"extractor": "create:block/extractor_powered",
|
||||||
|
"particle": "create:block/extractor_powered"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
{
|
||||||
|
"__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
|
||||||
|
"parent": "block/block",
|
||||||
|
"textures": {
|
||||||
|
"redstone_antenna": "create:block/redstone_antenna",
|
||||||
|
"extractor": "create:block/extractor",
|
||||||
|
"particle": "create:block/extractor"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "Bottom",
|
||||||
|
"from": [ 4, 2, -1 ],
|
||||||
|
"to": [ 12, 3, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 6, 7, 14, 8 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ] },
|
||||||
|
"up": { "texture": "#extractor", "uv": [ 9, 0, 15, 8 ], "rotation": 90 },
|
||||||
|
"down": { "texture": "#extractor", "uv": [ 0, 0, 6, 8 ], "rotation": 270 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Top",
|
||||||
|
"from": [ 4, 9, -1 ],
|
||||||
|
"to": [ 12, 10, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 6, 0, 14, 1 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0, 0, 6, 1 ] },
|
||||||
|
"up": { "texture": "#extractor", "uv": [ 0, 0, 6, 8 ], "rotation": 90 },
|
||||||
|
"down": { "texture": "#extractor", "uv": [ 9, 0, 15, 8 ], "rotation": 270 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Side",
|
||||||
|
"from": [ 4, 3, -1 ],
|
||||||
|
"to": [ 5, 9, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 9, 1, 15, 7 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 6, 1, 7, 7 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0, 1, 6, 7 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Side",
|
||||||
|
"from": [ 11, 3, -1 ],
|
||||||
|
"to": [ 12, 9, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0, 1, 6, 7 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 13, 1, 14, 7 ] },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 9, 1, 15, 7 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Center",
|
||||||
|
"from": [ 5, 3, 3 ],
|
||||||
|
"to": [ 11, 9, 4 ],
|
||||||
|
"faces": {
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 7, 1, 13, 7 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "FilterSpot",
|
||||||
|
"from": [ 5, 10, -0.6 ],
|
||||||
|
"to": [ 11, 12, 4 ],
|
||||||
|
"rotation": { "origin": [ 8, 11, -1 ], "axis": "x", "angle": 22.5 },
|
||||||
|
"faces": {
|
||||||
|
"north": { "texture": "#extractor", "uv": [ 13, 1, 15, 7 ], "rotation": 90 },
|
||||||
|
"east": { "texture": "#extractor", "uv": [ 0.1, 0, 4.7, 2 ], "rotation": 180 },
|
||||||
|
"south": { "texture": "#extractor", "uv": [ 4, 1, 5, 7 ], "rotation": 270 },
|
||||||
|
"west": { "texture": "#extractor", "uv": [ 0.1, 0, 4.7, 2 ] },
|
||||||
|
"up": { "texture": "#extractor", "uv": [ 0, 9, 5, 15 ], "rotation": 90 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AntennaX",
|
||||||
|
"from": [ 11, 7, 2 ],
|
||||||
|
"to": [ 14, 17, 3 ],
|
||||||
|
"faces": {
|
||||||
|
"north": { "texture": "#redstone_antenna", "uv": [ 0, 0, 3, 10 ] },
|
||||||
|
"south": { "texture": "#redstone_antenna", "uv": [ 0, 0, 3, 10 ] },
|
||||||
|
"down": { "texture": "#redstone_antenna", "uv": [ 0, 9, 3, 10 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AntennaZ",
|
||||||
|
"from": [ 12, 7, 1 ],
|
||||||
|
"to": [ 13, 17, 4 ],
|
||||||
|
"faces": {
|
||||||
|
"east": { "texture": "#redstone_antenna", "uv": [ 0, 0, 3, 10 ] },
|
||||||
|
"west": { "texture": "#redstone_antenna", "uv": [ 0, 0, 3, 10 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AntennaTop",
|
||||||
|
"from": [ 12, 15, 2 ],
|
||||||
|
"to": [ 13, 16, 3 ],
|
||||||
|
"faces": {
|
||||||
|
"up": { "texture": "#redstone_antenna", "uv": [ 1, 1, 2, 2 ] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AntennaDish",
|
||||||
|
"from": [ 10, 13, 0 ],
|
||||||
|
"to": [ 15, 13, 5 ],
|
||||||
|
"faces": {
|
||||||
|
"up": { "texture": "#redstone_antenna", "uv": [ 4, 0, 9, 5 ] },
|
||||||
|
"down": { "texture": "#redstone_antenna", "uv": [ 4, 0, 9, 5 ] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "create:block/extractor_wireless",
|
||||||
|
"textures": {
|
||||||
|
"redstone_antenna": "create:block/redstone_antenna_powered",
|
||||||
|
"extractor": "create:block/extractor_powered",
|
||||||
|
"particle": "create:block/extractor_powered"
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
"brass_casing": "create:block/brass_casing",
|
"brass_casing": "create:block/brass_casing",
|
||||||
"dark_oak_planks": "minecraft:block/dark_oak_planks",
|
"dark_oak_planks": "minecraft:block/dark_oak_planks",
|
||||||
"iron_block": "minecraft:block/iron_block",
|
"iron_block": "minecraft:block/iron_block",
|
||||||
|
"end": "create:block/stockpile_switch_end",
|
||||||
"particle": "create:block/brass_casing"
|
"particle": "create:block/brass_casing"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
|
@ -73,7 +74,7 @@
|
||||||
"faces": {
|
"faces": {
|
||||||
"north": { "texture": "#iron_block", "uv": [ 14, 2, 16, 14 ] },
|
"north": { "texture": "#iron_block", "uv": [ 14, 2, 16, 14 ] },
|
||||||
"south": { "texture": "#iron_block", "uv": [ 0, 2, 2, 14 ] },
|
"south": { "texture": "#iron_block", "uv": [ 0, 2, 2, 14 ] },
|
||||||
"west": { "texture": "#iron_block", "uv": [ 2, 2, 14, 14 ] },
|
"west": { "texture": "#end", "uv": [ 2, 2, 14, 14 ] },
|
||||||
"up": { "texture": "#iron_block", "uv": [ 2, 0, 14, 2 ], "rotation": 270 },
|
"up": { "texture": "#iron_block", "uv": [ 2, 0, 14, 2 ], "rotation": 270 },
|
||||||
"down": { "texture": "#iron_block", "uv": [ 2, 14, 14, 16 ], "rotation": 90 }
|
"down": { "texture": "#iron_block", "uv": [ 2, 14, 14, 16 ], "rotation": 90 }
|
||||||
}
|
}
|
||||||
|
|
10
src/main/resources/assets/create/models/item/extractor.json
Normal file
10
src/main/resources/assets/create/models/item/extractor.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"parent": "create:block/extractor_powered",
|
||||||
|
"display": {
|
||||||
|
"gui": {
|
||||||
|
"rotation": [ 30, 45, 0 ],
|
||||||
|
"translation": [ 0, 0, 0],
|
||||||
|
"scale":[ 0.625, 0.625, 0.625 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
src/main/resources/assets/create/models/item/filter.json
Normal file
8
src/main/resources/assets/create/models/item/filter.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "create:item/filter",
|
||||||
|
"layer1": "create:item/filter_1",
|
||||||
|
"layer2": "create:item/filter_2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"parent": "create:block/extractor_wireless_powered",
|
||||||
|
"display": {
|
||||||
|
"gui": {
|
||||||
|
"rotation": [ 30, 45, 0 ],
|
||||||
|
"translation": [ 0, 0, 0],
|
||||||
|
"scale":[ 0.625, 0.625, 0.625 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,10 @@
|
||||||
{
|
{
|
||||||
"parent": "create:block/shop_shelf"
|
"parent": "create:block/shop_shelf",
|
||||||
|
"display": {
|
||||||
|
"gui": {
|
||||||
|
"rotation": [ 30, 45, 0 ],
|
||||||
|
"translation": [ 0, 0, 0],
|
||||||
|
"scale":[ 0.625, 0.625, 0.625 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
BIN
src/main/resources/assets/create/textures/block/extractor.png
Normal file
BIN
src/main/resources/assets/create/textures/block/extractor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 491 B |
Binary file not shown.
After Width: | Height: | Size: 509 B |
Binary file not shown.
After Width: | Height: | Size: 364 B |
BIN
src/main/resources/assets/create/textures/item/filter.png
Normal file
BIN
src/main/resources/assets/create/textures/item/filter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 278 B |
BIN
src/main/resources/assets/create/textures/item/filter_1.png
Normal file
BIN
src/main/resources/assets/create/textures/item/filter_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 164 B |
BIN
src/main/resources/assets/create/textures/item/filter_2.png
Normal file
BIN
src/main/resources/assets/create/textures/item/filter_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 B |
Loading…
Reference in a new issue