Creative Crate Revival

- The creative crate is back on the menu
- Schematicannons with creative crates no longer require gunpowder to operate
- Creative crates can now be used for infinite item supply and voiding
- Added a few more advancements
This commit is contained in:
simibubi 2020-05-07 19:52:36 +02:00
parent 6c3c0600d3
commit 65853c9da0
35 changed files with 674 additions and 90 deletions

View file

@ -74,7 +74,7 @@ import com.simibubi.create.modules.logistics.block.diodes.ToggleLatchBlock;
import com.simibubi.create.modules.logistics.block.extractor.ExtractorBlock;
import com.simibubi.create.modules.logistics.block.extractor.LinkedExtractorBlock;
import com.simibubi.create.modules.logistics.block.funnel.FunnelBlock;
import com.simibubi.create.modules.logistics.block.inventories.CrateBlock;
import com.simibubi.create.modules.logistics.block.inventories.CreativeCrateBlock;
import com.simibubi.create.modules.logistics.block.inventories.FlexcrateBlock;
import com.simibubi.create.modules.logistics.block.transposer.LinkedTransposerBlock;
import com.simibubi.create.modules.logistics.block.transposer.TransposerBlock;
@ -182,10 +182,8 @@ public enum AllBlocks {
CONTACT(new ContactBlock()),
REDSTONE_BRIDGE(new RedstoneLinkBlock()),
STOCKSWITCH(new StockswitchBlock()),
WAREHOUSE_CRATE(new CrateBlock(Properties.from(Blocks.ANDESITE))),
FLEXCRATE(new FlexcrateBlock()),
FILTERED_CRATE(new CrateBlock(Properties.from(Blocks.ANDESITE))),
CREATIVE_CRATE(new CrateBlock(Properties.from(Blocks.ANDESITE))),
CREATIVE_CRATE(new CreativeCrateBlock(Properties.from(Blocks.ANDESITE))),
EXTRACTOR(new ExtractorBlock()),
VERTICAL_EXTRACTOR(new ExtractorBlock.Vertical()),
LINKED_EXTRACTOR(new LinkedExtractorBlock()),

View file

@ -82,6 +82,7 @@ import com.simibubi.create.modules.logistics.block.diodes.FlexpeaterTileEntityRe
import com.simibubi.create.modules.logistics.block.extractor.ExtractorTileEntity;
import com.simibubi.create.modules.logistics.block.extractor.LinkedExtractorTileEntity;
import com.simibubi.create.modules.logistics.block.funnel.FunnelTileEntity;
import com.simibubi.create.modules.logistics.block.inventories.CreativeCrateTileEntity;
import com.simibubi.create.modules.logistics.block.inventories.FlexcrateTileEntity;
import com.simibubi.create.modules.logistics.block.transposer.LinkedTransposerTileEntity;
import com.simibubi.create.modules.logistics.block.transposer.TransposerTileEntity;
@ -153,6 +154,7 @@ public enum AllTileEntities {
REDSTONE_BRIDGE(RedstoneLinkTileEntity::new, AllBlocks.REDSTONE_BRIDGE),
STOCKSWITCH(StockswitchTileEntity::new, AllBlocks.STOCKSWITCH),
FLEXCRATE(FlexcrateTileEntity::new, AllBlocks.FLEXCRATE),
CREATIVE_CRATE(CreativeCrateTileEntity::new, AllBlocks.CREATIVE_CRATE),
EXTRACTOR(ExtractorTileEntity::new, AllBlocks.EXTRACTOR, AllBlocks.VERTICAL_EXTRACTOR),
LINKED_EXTRACTOR(LinkedExtractorTileEntity::new, AllBlocks.LINKED_EXTRACTOR, AllBlocks.VERTICAL_LINKED_EXTRACTOR),
TRANSPOSER(TransposerTileEntity::new, AllBlocks.TRANSPOSER, AllBlocks.VERTICAL_TRANSPOSER),
@ -235,6 +237,7 @@ public enum AllTileEntities {
bind(FurnaceEngineTileEntity.class, new EngineRenderer<>());
bind(SpeedControllerTileEntity.class, new SpeedControllerRenderer());
bind(CreativeCrateTileEntity.class, new SmartTileEntityRenderer<>());
bind(RedstoneLinkTileEntity.class, new SmartTileEntityRenderer<>());
bind(ExtractorTileEntity.class, new SmartTileEntityRenderer<>());
bind(LinkedExtractorTileEntity.class, new SmartTileEntityRenderer<>());

View file

@ -26,6 +26,7 @@ public enum ScreenResources {
SCHEMATICANNON_PROGRESS_2("schematicannon.png", 122, 161, 16, 15),
SCHEMATICANNON_HIGHLIGHT("schematicannon.png", 0, 182, 28, 28),
SCHEMATICANNON_FUEL("schematicannon.png", 0, 215, 82, 4),
SCHEMATICANNON_FUEL_CREATIVE("schematicannon.png", 0, 219, 82, 4),
FLEXCRATE("flex_crate_and_stockpile_switch.png", 125, 129),
FLEXCRATE_DOUBLE("double_flexcrate.png", 197, 129),

View file

@ -16,11 +16,13 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.advancement.KineticBlockTrigger;
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem;
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.ComponentTier;
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.Advancement.Builder;
import net.minecraft.advancements.FrameType;
import net.minecraft.advancements.IRequirementsStrategy;
import net.minecraft.advancements.criterion.InventoryChangeTrigger;
import net.minecraft.advancements.criterion.PlacedBlockTrigger;
import net.minecraft.block.Block;
@ -28,6 +30,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
@ -55,7 +58,6 @@ public class CreateAdvancements implements IDataProvider {
.withCriterion("0", itemGathered(AllItems.ANDESITE_ALLOY.get()))
.register(t, id + ":andesite_alloy");
kineticsBranch(t, andesite_alloy);
Advancement water_wheel = advancement("water_wheel", AllBlocks.WATER_WHEEL.get(), TaskType.NORMAL)
@ -77,7 +79,7 @@ public class CreateAdvancements implements IDataProvider {
.withParent(andesite_alloy)
.withCriterion("0", itemGathered(AllBlocks.ANDESITE_CASING.get()))
.register(t, id + ":andesite_casing");
andesiteExpertLane(t, andesite_casing);
Advancement drill = kinecticAdvancement("drill", AllBlocks.DRILL, TaskType.NORMAL)
@ -89,9 +91,10 @@ public class CreateAdvancements implements IDataProvider {
.withCriterion("0", AllTriggers.BONK.instance())
.register(t, id + ":press");
Advancement rose_quartz = itemAdvancement("polished_rose_quartz", AllItems.POLISHED_ROSE_QUARTZ, TaskType.NORMAL)
.withParent(andesite_casing)
.register(t, id + ":polished_rose_quartz");
Advancement rose_quartz =
itemAdvancement("polished_rose_quartz", AllItems.POLISHED_ROSE_QUARTZ, TaskType.NORMAL)
.withParent(andesite_casing)
.register(t, id + ":polished_rose_quartz");
Advancement electron_tube = itemAdvancement("electron_tube", AllItems.ELECTRON_TUBE, TaskType.NORMAL)
.withParent(rose_quartz)
@ -123,6 +126,7 @@ public class CreateAdvancements implements IDataProvider {
.register(t, id + ":brass");
brassAge(t, brass);
copperAge(t, press);
}
void kineticsBranch(Consumer<Advancement> t, Advancement root) {
@ -166,6 +170,20 @@ public class CreateAdvancements implements IDataProvider {
}
void copperAge(Consumer<Advancement> t, Advancement root) {
String id = Create.ID;
Advancement copper_casing = advancement("copper_casing", AllBlocks.COPPER_CASING.get(), TaskType.GOAL)
.withParent(root)
.withCriterion("0", itemGathered(AllBlocks.COPPER_CASING.get()))
.register(t, id + ":copper_casing");
Advancement copper_end = deadEnd()
.withParent(copper_casing)
.withCriterion("0", itemGathered(AllBlocks.COPPER_CASING.get()))
.register(t, id + ":copper_end");
}
void brassAge(Consumer<Advancement> t, Advancement root) {
String id = Create.ID;
@ -182,7 +200,7 @@ public class CreateAdvancements implements IDataProvider {
.withParent(brass_casing)
.register(t, id + ":deployer");
Advancement fist_bump = advancement("fist_bump", AllBlocks.LARGE_COGWHEEL.get(), TaskType.SECRET)
Advancement fist_bump = advancement("fist_bump", AllBlocks.DEPLOYER.get(), TaskType.SECRET)
.withParent(deployer)
.withCriterion("0", AllTriggers.DEPLOYER_BOOP.instance())
.register(t, id + ":fist_bump");
@ -196,21 +214,44 @@ public class CreateAdvancements implements IDataProvider {
itemAdvancement("chromatic_compound", AllItems.CHROMATIC_COMPOUND, TaskType.NORMAL)
.withParent(crushing_wheel)
.register(t, id + ":chromatic_compound");
Advancement shadow_steel =
itemAdvancement("shadow_steel", AllItems.SHADOW_STEEL, TaskType.GOAL)
Advancement shadow_steel = itemAdvancement("shadow_steel", AllItems.SHADOW_STEEL, TaskType.GOAL)
.withParent(chromatic_compound)
.register(t, id + ":shadow_steel");
Advancement refined_radiance =
itemAdvancement("refined_radiance", AllItems.REFINED_RADIANCE, TaskType.GOAL)
Advancement refined_radiance = itemAdvancement("refined_radiance", AllItems.REFINED_RADIANCE, TaskType.GOAL)
.withParent(chromatic_compound)
.register(t, id + ":refined_radiance");
Advancement deforester = itemAdvancement("deforester", AllItems.DEFORESTER, TaskType.NORMAL)
.withParent(refined_radiance)
.register(t, id + ":deforester");
Advancement zapper = itemAdvancement("zapper", AllItems.PLACEMENT_HANDGUN, TaskType.NORMAL)
.withParent(refined_radiance)
.register(t, id + ":zapper");
ItemStack gunWithPurpurStuff = AllItems.PLACEMENT_HANDGUN.asStack();
for (Components c : Components.values())
BlockzapperItem.setTier(c, ComponentTier.Chromatic, gunWithPurpurStuff);
Advancement upgraded_zapper = advancement("upgraded_zapper", gunWithPurpurStuff, TaskType.CHALLENGE)
.withCriterion("0", AllTriggers.UPGRADED_ZAPPER.instance())
.withParent(zapper)
.register(t, id + ":upgraded_zapper");
Advancement symmetry_wand = itemAdvancement("symmetry_wand", AllItems.SYMMETRY_WAND, TaskType.NORMAL)
.withParent(refined_radiance)
.register(t, id + ":symmetry_wand");
Advancement shadow_end = deadEnd()
.withParent(shadow_steel)
.withCriterion("0", itemGathered(AllItems.SHADOW_STEEL.get()))
.register(t, id + ":shadow_end");
}
private void andesiteExpertLane(Consumer<Advancement> t, Advancement root) {
String id = Create.ID;
Advancement expert_lane_1 = advancement("expert_lane_1", Blocks.ANDESITE, TaskType.SILENT_GATE)
.withParent(root)
.withCriterion("0", itemGathered(AllBlocks.ANDESITE_CASING.get()))
@ -277,6 +318,7 @@ public class CreateAdvancements implements IDataProvider {
GOAL(FrameType.GOAL, true, true, false),
SECRET(FrameType.GOAL, true, true, true),
SILENT_GATE(FrameType.CHALLENGE, false, false, false),
CHALLENGE(FrameType.CHALLENGE, true, true, false),
;
@ -300,6 +342,14 @@ public class CreateAdvancements implements IDataProvider {
}
public Builder advancement(String name, IItemProvider icon, TaskType type) {
return advancement(name, new ItemStack(icon), type);
}
public Builder deadEnd() {
return advancement("eob", Items.OAK_SAPLING, TaskType.SILENT_GATE);
}
public Builder advancement(String name, ItemStack icon, TaskType type) {
return Advancement.Builder
.builder()
.withDisplay(icon, new TranslationTextComponent(LANG + name),

View file

@ -30,6 +30,7 @@ public class AllTriggers {
SPEED_READ = simple("speed_read"),
BASIN_THROW = simple("basin"),
PRESS_COMPACT = simple("compact"),
UPGRADED_ZAPPER = simple("upgraded_zapper"),
MIXER_MIX = simple("mixer");
private static SimpleTrigger simple(String id) {

View file

@ -1,6 +1,7 @@
package com.simibubi.create.foundation.behaviour.filtering;
import java.util.function.Consumer;
import java.util.function.Supplier;
import com.simibubi.create.AllPackets;
import com.simibubi.create.foundation.behaviour.ValueBoxTransform;
@ -29,6 +30,7 @@ public class FilteringBehaviour extends TileEntityBehaviour {
private ItemStack filter;
public int count;
private Consumer<ItemStack> callback;
private Supplier<Boolean> isActive;
int scrollableValue;
int ticksUntilScrollPacket;
@ -40,6 +42,7 @@ public class FilteringBehaviour extends TileEntityBehaviour {
slotPositioning = slot;
showCount = false;
callback = stack -> {};
isActive = () -> true;
textShift = Vec3d.ZERO;
count = 0;
ticksUntilScrollPacket = -1;
@ -93,6 +96,11 @@ public class FilteringBehaviour extends TileEntityBehaviour {
callback = filterCallback;
return this;
}
public FilteringBehaviour onlyActiveWhen(Supplier<Boolean> condition) {
isActive = condition;
return this;
}
public FilteringBehaviour showCount() {
showCount = true;
@ -161,5 +169,9 @@ public class FilteringBehaviour extends TileEntityBehaviour {
public boolean anyAmount() {
return count == 0;
}
public boolean isActive() {
return isActive.get();
}
}

View file

@ -41,6 +41,8 @@ public class FilteringHandler {
FilteringBehaviour behaviour = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE);
if (behaviour == null)
return;
if (!behaviour.isActive())
return;
BlockRayTraceResult ray = RaycastHelper.rayTraceRange(world, player, 10);
if (ray == null)

View file

@ -41,6 +41,8 @@ public class FilteringRenderer {
FilteringBehaviour behaviour = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE);
if (behaviour == null)
return;
if (!behaviour.isActive())
return;
if (Minecraft.getInstance().player.isSneaking())
return;
@ -75,6 +77,8 @@ public class FilteringRenderer {
FilteringBehaviour behaviour = TileEntityBehaviour.get(tileEntityIn, FilteringBehaviour.TYPE);
if (behaviour == null)
return;
if (!behaviour.isActive())
return;
if (behaviour.getFilter().isEmpty())
return;

View file

@ -7,6 +7,7 @@ import java.util.Set;
import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
@ -110,8 +111,10 @@ public class BlockzapperItem extends ZapperItem implements IHaveCustomItemModel
continue;
if (!player.isCreative() && BlockHelper.findAndRemoveInInventory(selectedState, player, 1) == 0) {
player.getCooldownTracker().setCooldown(stack.getItem(), 20);
player.sendStatusMessage(
new StringTextComponent(TextFormatting.RED + Lang.translate("blockzapper.empty")), true);
player
.sendStatusMessage(
new StringTextComponent(TextFormatting.RED + Lang.translate("blockzapper.empty")),
true);
return false;
}
@ -119,9 +122,9 @@ public class BlockzapperItem extends ZapperItem implements IHaveCustomItemModel
dropBlocks(world, player, stack, face, placed);
for (Direction updateDirection : Direction.values())
selectedState = selectedState.updatePostPlacement(updateDirection,
world.getBlockState(placed.offset(updateDirection)), world, placed,
placed.offset(updateDirection));
selectedState = selectedState
.updatePostPlacement(updateDirection, world.getBlockState(placed.offset(updateDirection)),
world, placed, placed.offset(updateDirection));
BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, placed);
IFluidState ifluidstate = world.getFluidState(placed);
@ -132,9 +135,20 @@ public class BlockzapperItem extends ZapperItem implements IHaveCustomItemModel
return false;
}
if (player instanceof ServerPlayerEntity)
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, placed,
new ItemStack(selectedState.getBlock()));
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
CriteriaTriggers.PLACED_BLOCK.trigger(serverPlayer, placed, new ItemStack(selectedState.getBlock()));
boolean fullyUpgraded = true;
for (Components c : Components.values()) {
if (getTier(c, stack) != ComponentTier.Chromatic) {
fullyUpgraded = false;
break;
}
}
if (fullyUpgraded)
AllTriggers.UPGRADED_ZAPPER.trigger(serverPlayer);
}
}
return true;
@ -179,8 +193,9 @@ public class BlockzapperItem extends ZapperItem implements IHaveCustomItemModel
Vec3d start = player.getPositionVec().add(0, player.getEyeHeight(), 0);
Vec3d range = player.getLookVec().scale(getRange(stack));
BlockRayTraceResult raytrace = player.world.rayTraceBlocks(
new RayTraceContext(start, start.add(range), BlockMode.COLLIDER, FluidMode.NONE, player));
BlockRayTraceResult raytrace = player.world
.rayTraceBlocks(
new RayTraceContext(start, start.add(range), BlockMode.COLLIDER, FluidMode.NONE, player));
BlockPos pos = raytrace.getPos().toImmutable();
if (pos == null)
@ -318,8 +333,8 @@ public class BlockzapperItem extends ZapperItem implements IHaveCustomItemModel
Block.spawnDrops(worldIn.getBlockState(placed), worldIn, playerIn.getPosition(), tileentity);
if (getTier(Components.Retriever, item) == ComponentTier.Chromatic)
for (ItemStack stack : Block.getDrops(worldIn.getBlockState(placed), (ServerWorld) worldIn, placed,
tileentity))
for (ItemStack stack : Block
.getDrops(worldIn.getBlockState(placed), (ServerWorld) worldIn, placed, tileentity))
if (!playerIn.inventory.addItemStackToInventory(stack))
Block.spawnAsEntity(worldIn, placed, stack);
}

View file

@ -34,7 +34,7 @@ public class LatchBlock extends ToggleLatchBlock {
Direction direction = state.get(HORIZONTAL_FACING);
Direction left = direction.rotateY();
Direction right = direction.rotateYCCW();
boolean shouldSide = worldIn.isBlockPowered(pos.offset(left)) || worldIn.isBlockPowered(pos.offset(right));
boolean shouldSide = worldIn.isSidePowered(pos, left) || worldIn.isSidePowered(pos, right);
TickPriority tickpriority = TickPriority.HIGH;
if (this.isFacingTowardsRepeater(worldIn, pos, state))

View file

@ -0,0 +1,37 @@
package com.simibubi.create.modules.logistics.block.inventories;
import java.util.List;
import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.AxisDirection;
public abstract class CrateTileEntity extends SmartTileEntity {
public CrateTileEntity(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {}
public boolean isDoubleCrate() {
return getBlockState().get(FlexcrateBlock.DOUBLE);
}
public boolean isSecondaryCrate() {
if (!hasWorld())
return false;
if (!(getBlockState().getBlock() instanceof CrateBlock))
return false;
return isDoubleCrate() && getFacing().getAxisDirection() == AxisDirection.NEGATIVE;
}
public Direction getFacing() {
return getBlockState().get(FlexcrateBlock.FACING);
}
}

View file

@ -0,0 +1,36 @@
package com.simibubi.create.modules.logistics.block.inventories;
import com.simibubi.create.foundation.block.ITE;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class CreativeCrateBlock extends CrateBlock implements ITE<CreativeCrateTileEntity> {
public CreativeCrateBlock(Properties p_i48415_1_) {
super(p_i48415_1_);
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new CreativeCrateTileEntity();
}
@Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
withTileEntityDo(worldIn, pos, CreativeCrateTileEntity::onPlaced);
}
@Override
public Class<CreativeCrateTileEntity> getTileEntityClass() {
return CreativeCrateTileEntity.class;
}
}

View file

@ -0,0 +1,52 @@
package com.simibubi.create.modules.logistics.block.inventories;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class CreativeCrateInventory implements IItemHandler {
private CreativeCrateTileEntity te;
public CreativeCrateInventory(CreativeCrateTileEntity te) {
this.te = te;
}
@Override
public int getSlots() {
return 2;
}
@Override
public ItemStack getStackInSlot(int slot) {
if (slot == 1)
return ItemStack.EMPTY;
ItemStack filter = te.filter.getFilter().copy();
if (!filter.isEmpty())
filter.setCount(filter.getMaxStackSize());
return filter;
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
return ItemStack.EMPTY;
}
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
ItemStack filter = te.filter.getFilter().copy();
if (!filter.isEmpty())
filter.setCount(amount);
return filter;
}
@Override
public int getSlotLimit(int slot) {
return getStackInSlot(slot).getMaxStackSize();
}
@Override
public boolean isItemValid(int slot, ItemStack stack) {
return true;
}
}

View file

@ -0,0 +1,106 @@
package com.simibubi.create.modules.logistics.block.inventories;
import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.foundation.behaviour.ValueBoxTransform;
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public class CreativeCrateTileEntity extends CrateTileEntity {
public CreativeCrateTileEntity() {
super(AllTileEntities.CREATIVE_CRATE.type);
inv = new CreativeCrateInventory(this);
itemHandler = LazyOptional.of(() -> inv);
}
FilteringBehaviour filter;
LazyOptional<IItemHandler> itemHandler;
private CreativeCrateInventory inv;
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
filter = createFilter();
filter.onlyActiveWhen(this::filterVisible);
filter.withCallback(this::filterChanged);
behaviours.add(filter);
}
private boolean filterVisible() {
if (!hasWorld() || isDoubleCrate() && !isSecondaryCrate())
return false;
return true;
}
private void filterChanged(ItemStack filter) {
if (!filterVisible())
return;
CreativeCrateTileEntity otherCrate = getOtherCrate();
if (otherCrate == null)
return;
if (ItemStack.areItemsEqual(filter, otherCrate.filter.getFilter()))
return;
otherCrate.filter.setFilter(filter);
}
private CreativeCrateTileEntity getOtherCrate() {
if (!AllBlocks.CREATIVE_CRATE.typeOf(getBlockState()))
return null;
TileEntity tileEntity = world.getTileEntity(pos.offset(getFacing()));
if (tileEntity instanceof CreativeCrateTileEntity)
return (CreativeCrateTileEntity) tileEntity;
return null;
}
public void onPlaced() {
if (!isDoubleCrate())
return;
CreativeCrateTileEntity otherCrate = getOtherCrate();
if (otherCrate == null)
return;
filter.withCallback($ -> {});
filter.setFilter(otherCrate.filter.getFilter());
filter.withCallback(this::filterChanged);
}
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return itemHandler.cast();
return super.getCapability(cap, side);
}
public FilteringBehaviour createFilter() {
return new FilteringBehaviour(this, new ValueBoxTransform() {
@Override
protected Vec3d getOrientation(BlockState state) {
return new Vec3d(0, 0, 90);
}
@Override
protected Vec3d getLocation(BlockState state) {
return new Vec3d(0.5, 13 / 16d, 0.5);
}
protected float getScale() {
return super.getScale() * 1.5f;
};
});
}
}

View file

@ -2,7 +2,6 @@ package com.simibubi.create.modules.logistics.block.inventories;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.foundation.block.SyncedTileEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@ -15,7 +14,6 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.capabilities.Capability;
@ -24,7 +22,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
public class FlexcrateTileEntity extends SyncedTileEntity implements INamedContainerProvider {
public class FlexcrateTileEntity extends CrateTileEntity implements INamedContainerProvider {
public class Inv extends ItemStackHandler {
public Inv() {
@ -81,20 +79,6 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
return new FlexcrateContainer(id, inventory, this);
}
public boolean isDoubleCrate() {
return getBlockState().get(FlexcrateBlock.DOUBLE);
}
public FlexcrateTileEntity getMainCrate() {
if (isSecondaryCrate())
return getOtherCrate();
return this;
}
public boolean isSecondaryCrate() {
return isDoubleCrate() && getFacing().getAxisDirection() == AxisDirection.NEGATIVE;
}
public FlexcrateTileEntity getOtherCrate() {
if (!AllBlocks.FLEXCRATE.typeOf(getBlockState()))
return null;
@ -104,10 +88,12 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
return null;
}
public Direction getFacing() {
return getBlockState().get(FlexcrateBlock.FACING);
public FlexcrateTileEntity getMainCrate() {
if (isSecondaryCrate())
return getOtherCrate();
return this;
}
public void onSplit() {
FlexcrateTileEntity other = getOtherCrate();
if (other == null)

View file

@ -82,18 +82,20 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
resetButton = new IconButton(x + 106, y + 55, ScreenResources.I_STOP);
resetIndicator = new Indicator(x + 106, y + 50, "");
resetIndicator.state = State.RED;
Collections.addAll(widgets, playButton, playIndicator, pauseButton, pauseIndicator, resetButton,
resetIndicator);
Collections
.addAll(widgets, playButton, playIndicator, pauseButton, pauseIndicator, resetButton, resetIndicator);
// Replace settings
replaceLevelButtons = new Vector<>(4);
replaceLevelIndicators = new Vector<>(4);
List<ScreenResources> icons = ImmutableList.of(ScreenResources.I_DONT_REPLACE, ScreenResources.I_REPLACE_SOLID,
ScreenResources.I_REPLACE_ANY, ScreenResources.I_REPLACE_EMPTY);
List<String> toolTips = ImmutableList.of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"),
Lang.translate("gui.schematicannon.option.replaceWithSolid"),
Lang.translate("gui.schematicannon.option.replaceWithAny"),
Lang.translate("gui.schematicannon.option.replaceWithEmpty"));
List<ScreenResources> icons = ImmutableList
.of(ScreenResources.I_DONT_REPLACE, ScreenResources.I_REPLACE_SOLID, ScreenResources.I_REPLACE_ANY,
ScreenResources.I_REPLACE_EMPTY);
List<String> toolTips = ImmutableList
.of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"),
Lang.translate("gui.schematicannon.option.replaceWithSolid"),
Lang.translate("gui.schematicannon.option.replaceWithAny"),
Lang.translate("gui.schematicannon.option.replaceWithEmpty"));
for (int i = 0; i < 4; i++) {
replaceLevelIndicators.add(new Indicator(x + 16 + i * 18, y + 96, ""));
@ -189,8 +191,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
boolean enabled = indicator.state == State.ON;
List<String> tip = button.getToolTip();
tip.add(TextFormatting.BLUE + (enabled ? optionEnabled : optionDisabled));
tip.addAll(TooltipHelper.cutString(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"),
GRAY, GRAY));
tip
.addAll(TooltipHelper
.cutString(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"), GRAY,
GRAY));
}
@Override
@ -221,8 +225,9 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
font.drawStringWithShadow(msg, guiLeft + 20 + 96 - stringWidth / 2, guiTop + 30, 0xCCDDFF);
font.drawString(settingsTitle, guiLeft + 20 + 13, guiTop + 84, ScreenResources.FONT_COLOR);
font.drawString(playerInventory.getDisplayName().getFormattedText(), guiLeft - 10 + 7, guiTop + 145 + 6,
0x666666);
font
.drawString(playerInventory.getDisplayName().getFormattedText(), guiLeft - 10 + 7, guiTop + 145 + 6,
0x666666);
// to see or debug the bounds of the extra area uncomment the following lines
// Rectangle2d r = extraAreas.get(0);
@ -268,6 +273,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
protected void renderFuelBar(float amount) {
ScreenResources sprite = ScreenResources.SCHEMATICANNON_FUEL;
if (container.getTileEntity().hasCreativeCrate) {
ScreenResources.SCHEMATICANNON_FUEL_CREATIVE.draw(this, guiLeft + 20 + 73, guiTop + 135);
return;
}
minecraft.getTextureManager().bindTexture(sprite.location);
blit(guiLeft + 20 + 73, guiTop + 135, sprite.startX, sprite.startY, (int) (sprite.width * amount),
sprite.height);
@ -287,11 +296,14 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
+ te.inventory.getStackInSlot(4).getCount() * (te.getFuelAddedByGunPowder() / fuelUsageRate));
List<String> tooltip = new ArrayList<>();
tooltip.add(Lang.translate(_gunpowderLevel, "" + (int) (te.fuelLevel * 100)));
tooltip.add(GRAY + Lang.translate(_shotsRemaining, "" + TextFormatting.BLUE + shotsLeft));
float f = te.hasCreativeCrate ? 100 : te.fuelLevel * 100;
tooltip.add(Lang.translate(_gunpowderLevel, "" + (int) f));
if (!te.hasCreativeCrate)
tooltip.add(GRAY + Lang.translate(_shotsRemaining, "" + TextFormatting.BLUE + shotsLeft));
if (shotsLeftWithItems != shotsLeft)
tooltip.add(GRAY
+ Lang.translate(_shotsRemainingWithBackup, "" + TextFormatting.BLUE + shotsLeftWithItems));
tooltip
.add(GRAY + Lang
.translate(_shotsRemainingWithBackup, "" + TextFormatting.BLUE + shotsLeftWithItems));
renderTooltip(tooltip, mouseX, mouseY);
}

View file

@ -359,7 +359,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
}
// Check Fuel
if (fuelLevel <= 0) {
if (fuelLevel <= 0 && !hasCreativeCrate) {
fuelLevel = 0;
state = State.PAUSED;
statusMsg = "noGunpowder";
@ -466,7 +466,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
}
public double getFuelUsageRate() {
return config().schematicannonFuelUsage.get() / 100f;
return hasCreativeCrate ? 0 : config().schematicannonFuelUsage.get() / 100f;
}
protected void initializePrinter(ItemStack blueprint) {
@ -556,8 +556,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
int amountFound = 0;
for (IItemHandler iItemHandler : attachedInventories) {
amountFound += ItemHelper.extract(iItemHandler, s -> ItemRequirement.validate(required, s),
ExtractionCountMode.UPTO, required.getCount(), true).getCount();
amountFound += ItemHelper
.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO,
required.getCount(), true)
.getCount();
if (amountFound < required.getCount())
continue;
@ -570,14 +572,16 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
if (!simulate && success) {
int amountFound = 0;
for (IItemHandler iItemHandler : attachedInventories) {
amountFound += ItemHelper.extract(iItemHandler, s -> ItemRequirement.validate(required, s),
ExtractionCountMode.UPTO, required.getCount(), false).getCount();
amountFound += ItemHelper
.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO,
required.getCount(), false)
.getCount();
if (amountFound < required.getCount())
continue;
break;
}
}
return success;
}
@ -618,14 +622,16 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
public void finishedPrinting() {
inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1,
new ItemStack(AllItems.EMPTY_BLUEPRINT.get(), inventory.getStackInSlot(1).getCount() + 1));
inventory
.setStackInSlot(1,
new ItemStack(AllItems.EMPTY_BLUEPRINT.get(), inventory.getStackInSlot(1).getCount() + 1));
state = State.STOPPED;
statusMsg = "finished";
resetPrinter();
target = getPos().add(1, 0, 0);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), AllSoundEvents.SCHEMATICANNON_FINISH.get(),
SoundCategory.BLOCKS, 1, .7f);
world
.playSound(null, pos.getX(), pos.getY(), pos.getZ(), AllSoundEvents.SCHEMATICANNON_FINISH.get(),
SoundCategory.BLOCKS, 1, .7f);
sendUpdate = true;
}
@ -703,6 +709,8 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
}
protected void refillFuelIfPossible() {
if (hasCreativeCrate)
return;
if (1 - fuelLevel + 1 / 128f < getFuelAddedByGunPowder())
return;
if (inventory.getStackInSlot(4).isEmpty())
@ -772,8 +780,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
}
public void playFiringSound() {
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), AllSoundEvents.SCHEMATICANNON_LAUNCH_BLOCK.get(),
SoundCategory.BLOCKS, .1f, 1.1f);
world
.playSound(null, pos.getX(), pos.getY(), pos.getZ(), AllSoundEvents.SCHEMATICANNON_LAUNCH_BLOCK.get(),
SoundCategory.BLOCKS, .1f, 1.1f);
}
public void sendToContainer(PacketBuffer buffer) {
@ -837,8 +846,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
}
public void addBehaviours(List<TileEntityBehaviour> behaviours) {}
@Override
public void lazyTick() {

View file

@ -131,9 +131,7 @@
"block.create.contact": "Redstone Contact",
"block.create.redstone_bridge": "Redstone Link",
"block.create.stockswitch": "Stockpile Switch",
"block.create.warehouse_crate": "Warehouse Crate",
"block.create.flexcrate": "Adjustable Crate",
"block.create.filtered_crate": "Filtered Crate",
"block.create.creative_crate": "The Endless Crate",
"block.create.extractor": "Extractor",
"block.create.belt_funnel": "Funnel",
@ -683,6 +681,8 @@
"advancement.create.brass.desc": "Use Crushed Copper and Crushed Zinc to create some Brass.",
"advancement.create.brass_casing": "The Brass Age",
"advancement.create.brass_casing.desc": "Use newly obtained Brass and some Wood to create a more advanced Casing.",
"advancement.create.copper_casing": "The Copper Age",
"advancement.create.copper_casing.desc": "Use some copper sheets to create Copper Casing.",
"advancement.create.crafter": "Automated Assembly",
"advancement.create.crafter.desc": "Place and power some Mechanical Crafters",
@ -700,6 +700,18 @@
"advancement.create.refined_radiance": "Bright and Inspiring",
"advancement.create.refined_radiance.desc": "Create Refined Radiance, a powerful chromatic substance.",
"advancement.create.zapper": "Building with style",
"advancement.create.zapper.desc": "Craft a Blockzapper. A radiant laser gun that helps you build.",
"advancement.create.upgraded_zapper": "Radiant Overdrive",
"advancement.create.upgraded_zapper.desc": "Create and activate a fully upgraded Blockzapper.",
"advancement.create.symmetry_wand": "Radiant Mirrors",
"advancement.create.symmetry_wand.desc": "Craft a Staff of Symmetry.",
"advancement.create.deforester": "Radiant Chopping",
"advancement.create.deforester.desc": "Craft a Deforester, and say goodbye to the local forest.",
"advancement.create.eob": "End of Beta",
"advancement.create.eob.desc": "Expect more content here in the future. <3",
"create.subtitle.schematicannon_launch_block": "Schematicannon shoots",
"create.subtitle.schematicannon_finish": "Schematicannon finishes",
"create.subtitle.slime_added": "Slime squishes",
@ -1074,6 +1086,11 @@
"block.create.flexcrate.tooltip.summary": "This _Storage_ _Container_ allows Manual control over its capacity. It can hold up to _16_ _Stacks_ of any Item. Supports _Redstone_ _Comparators_.",
"block.create.flexcrate.tooltip.control1": "When R-Clicked",
"block.create.flexcrate.tooltip.action1": "Opens the _Interface_.",
"block.create.creative_crate.tooltip": "THE ENDLESS CRATE",
"block.create.creative_crate.tooltip.summary": "This _Storage_ _Container_ allows infinite replication of any item. Place next to a _Schematicannon_ to remove any material requirements.",
"block.create.creative_crate.tooltip.condition1": "When Item in Filter Slot",
"block.create.creative_crate.tooltip.behaviour1": "Anything _extracting_ from this container will provide an _endless_ _supply_ of the item specified. Items _inserted_ into this crate will be _voided._",
"block.create.extractor.tooltip": "EXTRACTOR",
"block.create.extractor.tooltip.summary": "_Takes_ _Items_ from an attached _Inventory_ and drops them onto the ground. Will not drop Items unless the space is clear. Can be assigned an item-stack as a _filter_.",
@ -1204,9 +1221,5 @@
"tool.create.rose_quartz.tooltip": "ROSE QUARTZ TOOLS",
"tool.create.rose_quartz.tooltip.summary": "This tool grants you a _greater_ _reach_ for _breaking_ _blocks_ or _placing_ _blocks_ from the off-hand.",
"block.create.warehouse_crate.tooltip": "WIP",
"block.create.filtered_crate.tooltip": "WIP",
"block.create.creative_crate.tooltip": "WIP",
"itemGroup.create": "Create"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

After

Width:  |  Height:  |  Size: 419 B

View file

@ -0,0 +1,35 @@
{
"parent": "create:press",
"display": {
"icon": {
"item": "create:copper_casing"
},
"title": {
"translate": "advancement.create.copper_casing"
},
"description": {
"translate": "advancement.create.copper_casing.desc"
},
"frame": "goal",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"0": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "create:copper_casing"
}
]
}
}
},
"requirements": [
[
"0"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "create:copper_casing",
"display": {
"icon": {
"item": "minecraft:oak_sapling"
},
"title": {
"translate": "advancement.create.eob"
},
"description": {
"translate": "advancement.create.eob.desc"
},
"frame": "challenge",
"show_toast": false,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"0": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "create:copper_casing"
}
]
}
}
},
"requirements": [
[
"0"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "create:refined_radiance",
"display": {
"icon": {
"item": "create:deforester"
},
"title": {
"translate": "advancement.create.deforester"
},
"description": {
"translate": "advancement.create.deforester.desc"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"0": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "create:deforester"
}
]
}
}
},
"requirements": [
[
"0"
]
]
}

View file

@ -2,7 +2,7 @@
"parent": "create:deployer",
"display": {
"icon": {
"item": "create:large_cogwheel"
"item": "create:deployer"
},
"title": {
"translate": "advancement.create.fist_bump"

View file

@ -0,0 +1,35 @@
{
"parent": "create:shadow_steel",
"display": {
"icon": {
"item": "minecraft:oak_sapling"
},
"title": {
"translate": "advancement.create.eob"
},
"description": {
"translate": "advancement.create.eob.desc"
},
"frame": "challenge",
"show_toast": false,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"0": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "create:shadow_steel"
}
]
}
}
},
"requirements": [
[
"0"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "create:refined_radiance",
"display": {
"icon": {
"item": "create:symmetry_wand"
},
"title": {
"translate": "advancement.create.symmetry_wand"
},
"description": {
"translate": "advancement.create.symmetry_wand.desc"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"0": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "create:symmetry_wand"
}
]
}
}
},
"requirements": [
[
"0"
]
]
}

View file

@ -0,0 +1,29 @@
{
"parent": "create:zapper",
"display": {
"icon": {
"item": "create:placement_handgun",
"nbt": "{Retriever:\"Chromatic\",Scope:\"Chromatic\",Amplifier:\"Chromatic\",Body:\"Chromatic\",Accelerator:\"Chromatic\"}"
},
"title": {
"translate": "advancement.create.upgraded_zapper"
},
"description": {
"translate": "advancement.create.upgraded_zapper.desc"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"0": {
"trigger": "create:upgraded_zapper"
}
},
"requirements": [
[
"0"
]
]
}

View file

@ -17,12 +17,21 @@
},
"criteria": {
"0": {
"trigger": "minecraft:placed_block",
"conditions": {
"block": "create:water_wheel"
}
},
"1": {
"trigger": "create:water_wheel"
}
},
"requirements": [
[
"0"
],
[
"1"
]
]
}

View file

@ -0,0 +1,35 @@
{
"parent": "create:refined_radiance",
"display": {
"icon": {
"item": "create:placement_handgun"
},
"title": {
"translate": "advancement.create.zapper"
},
"description": {
"translate": "advancement.create.zapper.desc"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"0": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "create:placement_handgun"
}
]
}
}
},
"requirements": [
[
"0"
]
]
}