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:
simibubi 2019-08-27 17:35:34 +02:00
parent 79d160e5bc
commit 22fc9d1100
61 changed files with 1206 additions and 702 deletions

View file

@ -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.GearboxBlock;
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.logistics.FlexcrateBlock;
import com.simibubi.create.modules.logistics.RedstoneBridgeBlock;
import com.simibubi.create.modules.logistics.StockswitchBlock;
import com.simibubi.create.modules.logistics.block.ExtractorBlock;
import com.simibubi.create.modules.logistics.block.FlexcrateBlock;
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.SchematicTableBlock;
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.PlaneSymmetryBlock;
import com.simibubi.create.modules.symmetry.block.TriplePlaneSymmetryBlock;
@ -94,6 +96,8 @@ public enum AllBlocks {
REDSTONE_BRIDGE(new RedstoneBridgeBlock()),
STOCKSWITCH(new StockswitchBlock()),
FLEXCRATE(new FlexcrateBlock()),
EXTRACTOR(new ExtractorBlock()),
LINKED_EXTRACTOR(new LinkedExtractorBlock()),
// Symmetry
SYMMETRY_PLANE(new PlaneSymmetryBlock()),

View file

@ -1,13 +1,13 @@
package com.simibubi.create;
import com.simibubi.create.modules.logistics.FlexcrateContainer;
import com.simibubi.create.modules.logistics.FlexcrateScreen;
import com.simibubi.create.modules.economy.ShopShelfContainer;
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.SchematicTableScreen;
import com.simibubi.create.modules.schematics.block.SchematicannonContainer;
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.ScreenManager;

View file

@ -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.BuilderGunModel;
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.BlueprintItem;
import com.simibubi.create.modules.symmetry.SymmetryWandItem;
import com.simibubi.create.modules.symmetry.client.SymmetryWandItemRenderer;
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.ModelResourceLocation;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
@ -45,6 +47,7 @@ public enum AllItems {
BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))),
BLUEPRINT(new BlueprintItem(standardProperties())),
BELT_CONNECTOR(new BeltItem(standardProperties())),
FILTER(new FilterItem(standardProperties())),
;
@ -81,6 +84,11 @@ public enum AllItems {
SYMMETRY_WAND, BUILDER_GUN,;
}
@OnlyIn(Dist.CLIENT)
public static void registerColorHandlers() {
Minecraft.getInstance().getItemColors().register(new FilterItem.Color(), FILTER.item);
}
@OnlyIn(Dist.CLIENT)
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
switch (renderer) {

View file

@ -7,6 +7,8 @@ import java.util.function.Supplier;
import com.simibubi.create.foundation.packet.NbtPacket;
import com.simibubi.create.foundation.packet.SimplePacketBase;
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.SchematicPlacePacket;
import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket;
@ -23,6 +25,8 @@ public enum AllPackets {
// Client to Server
NBT(NbtPacket.class, NbtPacket::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),
UPLOAD_SCHEMATIC(SchematicUploadPacket.class, SchematicUploadPacket::new),

View file

@ -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.GearshifterTileEntity;
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntityRenderer;
import com.simibubi.create.modules.logistics.FlexcrateTileEntity;
import com.simibubi.create.modules.logistics.RedstoneBridgeTileEntity;
import com.simibubi.create.modules.logistics.RedstoneBridgeTileEntityRenderer;
import com.simibubi.create.modules.logistics.StockswitchTileEntity;
import com.simibubi.create.modules.economy.ShopShelfTileEntity;
import com.simibubi.create.modules.logistics.block.FlexcrateTileEntity;
import com.simibubi.create.modules.logistics.block.RedstoneBridgeTileEntity;
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.SchematicannonRenderer;
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity;
import com.simibubi.create.modules.shopping.ShopShelfTileEntity;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;

View file

@ -66,6 +66,7 @@ public class Create {
ScrollFixer.init();
TOOL_MENU = new KeyBinding("Tool Menu (Hold)", KeyboardHelper.LALT, NAME);
ClientRegistry.registerKeyBinding(TOOL_MENU);
AllItems.registerColorHandlers();
});
}

View file

@ -27,13 +27,21 @@ public abstract class SyncedTileEntity extends TileEntity {
read(tag);
}
@Override
public SUpdateTileEntityPacket getUpdatePacket(){
return new SUpdateTileEntityPacket(getPos(), 1, writeToClient(new CompoundNBT()));
public void sendData() {
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 2 | 16);
}
public void causeBlockUpdate() {
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 1);
}
@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());
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.foundation.gui.widgets;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@ -42,6 +44,7 @@ public class Label extends AbstractSimiWidget {
if (text == null || text.isEmpty())
return;
GlStateManager.color4f(1, 1, 1, 1);
if (hasShadow)
font.drawStringWithShadow(text + suffix, x, y, color);
else

View file

@ -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);
}

View file

@ -0,0 +1,7 @@
package com.simibubi.create.foundation.utility;
public class ContainerListener {
}

View file

@ -143,14 +143,14 @@ public class RotationPropagator {
if (neighbourTE.hasSource() && neighbourTE.getSource().equals(addedTE.getPos())) {
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
addedTE.onSpeedChanged();
addedTE.notifyBlockUpdate();
addedTE.sendData();
continue;
}
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
addedTE.setSource(neighbourTE.getPos());
addedTE.onSpeedChanged();
addedTE.notifyBlockUpdate();
addedTE.sendData();
propagateNewSource(addedTE);
return;
}
@ -183,7 +183,7 @@ public class RotationPropagator {
neighbourTE.setSpeed(newSpeed);
neighbourTE.setSource(updateTE.getPos());
neighbourTE.onSpeedChanged();
neighbourTE.notifyBlockUpdate();
neighbourTE.sendData();
propagateNewSource(neighbourTE);
}
@ -234,7 +234,7 @@ public class RotationPropagator {
final KineticTileEntity currentTE = (KineticTileEntity) world.getTileEntity(pos);
currentTE.removeSource();
currentTE.notifyBlockUpdate();
currentTE.sendData();
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
if (neighbourTE.isSource()) {

View file

@ -51,10 +51,6 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
super.remove();
}
public void notifyBlockUpdate() {
this.world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 2 | 16);
}
@Override
public CompoundNBT write(CompoundNBT compound) {
compound.putFloat("Speed", getSpeed());

View file

@ -62,7 +62,7 @@ public class WaterWheelTileEntity extends KineticTileEntity {
RotationPropagator.handleRemoved(world, pos, this);
this.setSpeed(speed);
hasFlows = speed != 0;
notifyBlockUpdate();
sendData();
RotationPropagator.handleAdded(world, pos, this);
}

View file

@ -109,7 +109,7 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ITi
offset = movingConstruct.initialExtensionProgress;
movingPistons.add(this);
notifyBlockUpdate();
sendData();
getWorld().setBlockState(pos, getBlockState().with(MechanicalPistonBlock.STATE, PistonState.MOVING), 66);
for (BlockInfo block : movingConstruct.blocks.values()) {
BlockPos startPos = block.pos.offset(direction, movingConstruct.initialExtensionProgress);
@ -148,7 +148,7 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ITi
running = false;
movingPistons.remove(this);
movingConstruct = null;
notifyBlockUpdate();
sendData();
}
@Override

View file

@ -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.BlockState;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.shopping;
package com.simibubi.create.modules.economy;
import com.simibubi.create.AllContainers;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.shopping;
package com.simibubi.create.modules.economy;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.shopping;
package com.simibubi.create.modules.economy;
import java.util.UUID;
@ -20,7 +20,7 @@ public class ShopShelfTileEntity extends SyncedTileEntity implements INamedConta
private UUID owner;
public ShopShelfTileEntity() {
super(AllTileEntities.ShopShelfTileEntity.type);
super(AllTileEntities.SHOP_SHELF.type);
}
@Override

View file

@ -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);
}
}
}

View file

@ -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;
}
}

View file

@ -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();
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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());
}
}

View file

@ -0,0 +1,7 @@
package com.simibubi.create.modules.logistics;
public interface IReceiveWireless extends IHaveWireless {
public void setSignal(boolean powered);
}

View file

@ -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);
}
}

View file

@ -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;
}
}
}

View file

@ -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() {
}
}

View file

@ -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();
}
}

View file

@ -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.utility.ItemDescription;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.logistics;
package com.simibubi.create.modules.logistics.block;
import com.simibubi.create.AllContainers;
@ -63,8 +63,10 @@ public class FlexcrateContainer extends Container {
return ItemStack.EMPTY;
ItemStack stack = clickedSlot.getStack();
if (index < 16)
if (index < 16) {
mergeItemStack(stack, 16, inventorySlots.size(), false);
te.inventory.onContentsChanged(index);
}
else
mergeItemStack(stack, 0, 15, false);

View file

@ -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.PLAYER_INVENTORY;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPackets;
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 com.simibubi.create.modules.logistics.packet.ConfigureFlexcratePacket;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerInventory;
@ -72,6 +74,11 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
ScreenElementRenderer.renderBlock(this::getRenderedBlock);
}
@Override
public void removed() {
AllPackets.channel.sendToServer(new ConfigureFlexcratePacket(te.getPos(), allowedItems.getState()));
}
@Override
public void tick() {
super.tick();
@ -80,7 +87,7 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen<FlexcrateContai
if (lastModification >= 15) {
lastModification = -1;
AllPackets.channel.sendToServer(new ConfigureFlexcratePacket(te.getPos(), allowedItems.getState()));
}
}

View file

@ -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.foundation.block.SyncedTileEntity;
@ -17,6 +17,7 @@ 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.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
public class FlexcrateTileEntity extends SyncedTileEntity implements INamedContainerProvider {
@ -46,12 +47,18 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
markDirty();
itemCount = 0;
for (int i = 0; i < getSlots(); i++) {
itemCount += getStackInSlot(i).getCount();
}
}
}
public Inv inventory;
public int allowedAmount;
public int itemCount;
protected LazyOptional<IItemHandler> invHandler;
public FlexcrateTileEntity() {
this(AllTileEntities.FLEXCRATE.type);
@ -62,6 +69,7 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
allowedAmount = 512;
itemCount = 10;
inventory = new Inv();
invHandler = LazyOptional.of(() -> inventory);
}
@Override
@ -93,11 +101,16 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
buffer.writeCompoundTag(getUpdateTag());
}
@Override
public void remove() {
super.remove();
invHandler.invalidate();
}
@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return LazyOptional.of(() -> inventory).cast();
}
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return invHandler.cast();
return super.getCapability(capability, facing);
}

View file

@ -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) {
}
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.logistics;
package com.simibubi.create.modules.logistics.block;
import java.util.ArrayList;
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.text.ITextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
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),
DOWN_SHAPE = makeCuboidShape(2, 13, 2, 14, 16, 14);
public static final VoxelShape
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),
public static final VoxelShape 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),
WEST_SHAPE = makeCuboidShape(13, 1, 3, 17, 15, 13);
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)
return;
if (state.get(RECEIVER))
return;
boolean shouldPower = worldIn.getWorld().isBlockPowered(pos.offset(blockFacing.getOpposite()))
|| worldIn.getWorld().isBlockPowered(pos);
boolean previouslyPowered = state.get(POWERED);
if (previouslyPowered != worldIn.isBlockPowered(pos.offset(blockFacing.getOpposite()))) {
if (previouslyPowered != shouldPower) {
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
RedstoneBridgeTileEntity te = (RedstoneBridgeTileEntity) worldIn.getTileEntity(pos);
if (te == null)
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
public boolean canProvidePower(BlockState state) {
return state.get(POWERED) && state.get(RECEIVER);
@ -177,8 +161,13 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements ITool
if (player.isSneaking()) {
if (!worldIn.isRemote) {
worldIn.setBlockState(pos, state.cycle(RECEIVER));
te.blockChanged();
Boolean wasReceiver = state.get(RECEIVER);
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;
}

View file

@ -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;
}
}
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.logistics;
package com.simibubi.create.modules.logistics.block;
import org.apache.commons.lang3.tuple.Pair;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.modules.logistics;
package com.simibubi.create.modules.logistics.block;
import java.util.List;
@ -19,11 +19,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -44,6 +46,47 @@ public class StockswitchBlock extends HorizontalBlock implements ITooltip {
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
public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip,
ITooltipFlag flagIn) {

View file

@ -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;
@ -6,11 +6,13 @@ import java.util.Arrays;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPackets;
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
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 com.simibubi.create.modules.logistics.packet.ConfigureStockswitchPacket;
import net.minecraft.block.BlockState;
@ -21,10 +23,13 @@ public class StockswitchScreen extends AbstractSimiScreen {
private ScrollInput onAbove;
private Label onAboveLabel;
private int lastModification;
private StockswitchTileEntity te;
private float cursorPos;
public StockswitchScreen(StockswitchTileEntity te) {
this.te = te;
lastModification = -1;
}
@Override
@ -32,11 +37,13 @@ public class StockswitchScreen extends AbstractSimiScreen {
setWindowSize(STOCKSWITCH.width + 50, STOCKSWITCH.height);
super.init();
widgets.clear();
cursorPos = te.currentLevel == -1 ? 0 : te.currentLevel;
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")
.calling(state -> {
offBelowLabel.text = state + "%";
lastModification = 0;
if (onAbove.getState() - 4 <= state) {
onAbove.setState(state + 5);
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")
.calling(state -> {
onAboveLabel.text = state + "%";
lastModification = 0;
if (offBelow.getState() + 4 >= state) {
offBelow.setState(state - 5);
offBelow.onChanged();
@ -74,7 +82,6 @@ public class StockswitchScreen extends AbstractSimiScreen {
ScreenResources sprite = ScreenResources.STOCKSWITCH_INTERVAL;
float lowerBound = offBelow.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();
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_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;
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);
}
@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() {
GlStateManager.translated(guiLeft + STOCKSWITCH.width + 50, guiTop + 100, 0);
GlStateManager.rotatef(50, -.5f, 1, -.2f);

View file

@ -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;
}
}

View file

@ -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();
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View 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 }
}
}
}

View file

@ -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 }
}
}
}

View file

@ -9,6 +9,7 @@
"item.create.blueprint_and_quill": "Schematic and Quill",
"item.create.blueprint": "Schematic",
"item.create.belt_connector": "Mechanical Belt",
"item.create.filter": "Filter",
"block.create.gear": "Cogwheel",
"block.create.large_gear": "Large Cogwheel",
@ -37,6 +38,8 @@
"block.create.redstone_bridge": "Redstone Bridge",
"block.create.stockswitch": "Stockpile Switch",
"block.create.flexcrate": "FlexCrate",
"block.create.extractor": "Extractor",
"block.create.linked_extractor": "Linked Extractor",
"block.create.andesite_bricks": "Andesite Bricks",
"block.create.diorite_bricks": "Diorite Bricks",

View 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 }
}
}
]
}

View file

@ -0,0 +1,7 @@
{
"parent": "create:block/extractor",
"textures": {
"extractor": "create:block/extractor_powered",
"particle": "create:block/extractor_powered"
}
}

View file

@ -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 ] }
}
}
]
}

View file

@ -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"
}
}

View file

@ -6,6 +6,7 @@
"brass_casing": "create:block/brass_casing",
"dark_oak_planks": "minecraft:block/dark_oak_planks",
"iron_block": "minecraft:block/iron_block",
"end": "create:block/stockpile_switch_end",
"particle": "create:block/brass_casing"
},
"elements": [
@ -73,7 +74,7 @@
"faces": {
"north": { "texture": "#iron_block", "uv": [ 14, 2, 16, 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 },
"down": { "texture": "#iron_block", "uv": [ 2, 14, 14, 16 ], "rotation": 90 }
}

View 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 ]
}
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "item/generated",
"textures": {
"layer0": "create:item/filter",
"layer1": "create:item/filter_1",
"layer2": "create:item/filter_2"
}
}

View file

@ -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 ]
}
}
}

View file

@ -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 ]
}
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B