Skip to content

Commit

Permalink
- add fireproof tags for drives
Browse files Browse the repository at this point in the history
- update to latest ae2 version
  • Loading branch information
ProjectET committed Feb 3, 2022
1 parent 6bafbe6 commit ea98599
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 44 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ archives_base_name=AE2Things
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.44.0+1.18
ae2_version=10.0.0
ae2_version=10.1.0-beta.1
cloth_config_version=6.0.42
wthit_version=4.1.2
3 changes: 3 additions & 0 deletions src/main/java/io/github/projectet/ae2things/AE2Things.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public void onAe2Initialized() {

registerBlockwithItem("advanced_inscriber", ADVANCED_INSCRIBER);
((AEBaseEntityBlock<BEAdvancedInscriber>) ADVANCED_INSCRIBER).setBlockEntity(BEAdvancedInscriber.class, ADVANCED_INSCRIBER_BE, null, null);

// registerBlockwithItem("crystal_growth", CRYSTAL_GROWTH);
// ((AEBaseEntityBlock<BECrystalGrowth>) CRYSTAL_GROWTH).setBlockEntity(BECrystalGrowth.class, CRYSTAL_GROWTH_BE, null, null);

Upgrades.add(AEItems.SPEED_CARD, ADVANCED_INSCRIBER, 5);
Upgrades.add(AEItems.SPEED_CARD, CRYSTAL_GROWTH, 3);

ServerTickEvents.START_WORLD_TICK.register((world -> {
STORAGE_INSTANCE = StorageManager.getInstance(world.getServer());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package io.github.projectet.ae2things.block;

import appeng.block.AEBaseEntityBlock;
import appeng.menu.MenuOpener;
import appeng.menu.locator.MenuLocators;
import appeng.util.InteractionUtil;
import io.github.projectet.ae2things.AE2Things;
import io.github.projectet.ae2things.block.entity.BECrystalGrowth;
import io.github.projectet.ae2things.gui.crystalGrowth.CrystalGrowthMenu;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class BlockCrystalGrowth extends BlockWithEntity {
import javax.annotation.Nullable;

public class BlockCrystalGrowth extends AEBaseEntityBlock<BECrystalGrowth> {

public BlockCrystalGrowth(Settings settings) {
super(settings);
Expand All @@ -20,12 +28,24 @@ public BlockCrystalGrowth(Settings settings) {
@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new BECrystalGrowth(pos, state);
return AE2Things.CRYSTAL_GROWTH_BE.instantiate(pos, state);
}

@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, AE2Things.CRYSTAL_GROWTH_BE, BECrystalGrowth::tick);
public ActionResult onActivated(final World level, final BlockPos pos, final PlayerEntity p,
final Hand hand,
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (!InteractionUtil.isInAlternateUseMode(p)) {
final BECrystalGrowth cg = (BECrystalGrowth) level.getBlockEntity(pos);
if (cg != null) {
if (!level.isClient()) {
hit.getSide();
MenuOpener.open(CrystalGrowthMenu.CRYSTAL_GROWTH_SHT, p,
MenuLocators.forBlockEntity(cg));
}
return ActionResult.success(level.isClient());
}
}
return ActionResult.PASS;
}
}
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
package io.github.projectet.ae2things.block.entity;

import appeng.api.inventories.InternalInventory;
import appeng.api.networking.IGridNode;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.upgrades.IUpgradeInventory;
import appeng.api.upgrades.IUpgradeableObject;
import appeng.api.upgrades.UpgradeInventories;
import appeng.blockentity.grid.AENetworkPowerBlockEntity;
import appeng.util.inv.AppEngInternalInventory;
import io.github.projectet.ae2things.AE2Things;
import io.github.projectet.ae2things.inventory.DefaultInventory;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class BECrystalGrowth extends BlockEntity implements DefaultInventory, SidedInventory {
public class BECrystalGrowth extends AENetworkPowerBlockEntity implements IGridTickable, IUpgradeableObject {

DefaultedList<ItemStack> inventory = DefaultedList.ofSize(30);
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 27);
private IUpgradeInventory upgrades;

public BECrystalGrowth(BlockPos pos, BlockState state) {
super(AE2Things.CRYSTAL_GROWTH_BE, pos, state);
upgrades = UpgradeInventories.forMachine(AE2Things.CRYSTAL_GROWTH, 3, this::saveChanges);
}

@Override
public DefaultedList<ItemStack> getItems() {
public TickingRequest getTickingRequest(IGridNode node) {
return null;
}

@Override
public int[] getAvailableSlots(Direction side) {
return new int[0];
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
return null;
}

@Override
public boolean canInsert(int slot, ItemStack stack, @Nullable Direction dir) {
return false;
public InternalInventory getInternalInventory() {
return inventory;
}

@Override
public boolean canExtract(int slot, ItemStack stack, Direction dir) {
return false;
}
public void onChangeInventory(InternalInventory inv, int slot) {

public static void tick(World world, BlockPos pos, BlockState state, BECrystalGrowth blockEntity) {
}

@Override
public IUpgradeInventory getUpgrades() {
return upgrades;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package io.github.projectet.ae2things.command;

public class Command {
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AdvancedInscriberMenu(int syncId, PlayerInventory playerInventory, BEAdva

@Override
protected void standardDetectAndSendChanges() {
if (isServer()) {
if (isServerSide()) {
this.maxProcessingTime = getHost().getMaxProcessingTime();
this.processingTime = getHost().getProcessingTime();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package io.github.projectet.ae2things.gui.crystalGrowth;

public class CrystalGrowthMenu {
import appeng.menu.implementations.MenuTypeBuilder;
import appeng.menu.implementations.UpgradeableMenu;
import io.github.projectet.ae2things.block.entity.BECrystalGrowth;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.ScreenHandlerType;

public class CrystalGrowthMenu extends UpgradeableMenu<BECrystalGrowth> {

public static ScreenHandlerType<CrystalGrowthMenu> CRYSTAL_GROWTH_SHT = MenuTypeBuilder.create(CrystalGrowthMenu::new, BECrystalGrowth.class).build("crystal_growth");

public CrystalGrowthMenu(int id, PlayerInventory ip, BECrystalGrowth crystalGrowth) {
super(CRYSTAL_GROWTH_SHT, id, ip, crystalGrowth);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package io.github.projectet.ae2things.gui.crystalGrowth;

public class CrystalGrowthRootPanel {
import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.style.ScreenStyle;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;

public class CrystalGrowthRootPanel extends UpgradeableScreen<CrystalGrowthMenu> {

public CrystalGrowthRootPanel(CrystalGrowthMenu menu, PlayerInventory playerInventory, Text title, ScreenStyle style) {
super(menu, playerInventory, title, style);
}
}
12 changes: 5 additions & 7 deletions src/main/java/io/github/projectet/ae2things/item/AETItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
import appeng.api.client.StorageCellModels;
import appeng.core.definitions.AEItems;
import io.github.projectet.ae2things.AE2Things;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class AETItems {

public static final Item DISK_HOUSING = new Item(new FabricItemSettings().maxCount(64).group(AE2Things.ITEM_GROUP));
public static final Item DISK_DRIVE_1K = new DISKDrive(new FabricItemSettings().maxCount(1).group(AE2Things.ITEM_GROUP), AEItems.CELL_COMPONENT_1K.asItem(), 1, 0.5f);
public static final Item DISK_DRIVE_4K = new DISKDrive(new FabricItemSettings().maxCount(1).group(AE2Things.ITEM_GROUP), AEItems.CELL_COMPONENT_4K.asItem(), 4, 1.0f);
public static final Item DISK_DRIVE_16K = new DISKDrive(new FabricItemSettings().maxCount(1).group(AE2Things.ITEM_GROUP), AEItems.CELL_COMPONENT_16K.asItem(), 16, 1.5f);
public static final Item DISK_DRIVE_64K = new DISKDrive(new FabricItemSettings().maxCount(1).group(AE2Things.ITEM_GROUP), AEItems.CELL_COMPONENT_64K.asItem(), 64, 2.0f);
public static final Item DISK_HOUSING = new Item(new FabricItemSettings().maxCount(64).group(AE2Things.ITEM_GROUP).fireproof());
public static final Item DISK_DRIVE_1K = new DISKDrive(AEItems.CELL_COMPONENT_1K.asItem(), 1, 0.5f);
public static final Item DISK_DRIVE_4K = new DISKDrive(AEItems.CELL_COMPONENT_4K.asItem(), 4, 1.0f);
public static final Item DISK_DRIVE_16K = new DISKDrive(AEItems.CELL_COMPONENT_16K.asItem(), 16, 1.5f);
public static final Item DISK_DRIVE_64K = new DISKDrive(AEItems.CELL_COMPONENT_64K.asItem(), 64, 2.0f);

public static final Identifier MODEL_DISK_DRIVE_1K = new Identifier("ae2things:model/drive/cells/disk_1k");
public static final Identifier MODEL_DISK_DRIVE_4K = new Identifier("ae2things:model/drive/cells/disk_4k");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import appeng.api.config.FuzzyMode;
import appeng.api.stacks.AEKeyType;
import appeng.api.storage.StorageCells;
import appeng.api.storage.cells.CellState;
import appeng.api.upgrades.IUpgradeInventory;
import appeng.api.upgrades.UpgradeInventories;
Expand All @@ -13,8 +12,8 @@
import io.github.projectet.ae2things.AE2Things;
import io.github.projectet.ae2things.storage.DISKCellHandler;
import io.github.projectet.ae2things.storage.IDISKCellItem;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
Expand All @@ -40,8 +39,8 @@ public class DISKDrive extends Item implements IDISKCellItem, AEToolItem {
private final double idleDrain;
private final ItemConvertible coreItem;

public DISKDrive(Settings settings, ItemConvertible coreItem, int kilobytes, double idleDrain) {
super(settings.group(AE2Things.ITEM_GROUP));
public DISKDrive(ItemConvertible coreItem, int kilobytes, double idleDrain) {
super(new FabricItemSettings().maxCount(1).group(AE2Things.ITEM_GROUP).fireproof());
this.bytes = kilobytes * 1000;
this.coreItem = coreItem;
this.idleDrain = idleDrain;
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"depends": {
"fabricloader": ">=0.12.12",
"fabric": "*",
"ae2": ">=10.0.0-beta.3",
"ae2": ">=10.1.0-beta.1",
"minecraft": "1.18.1"
}
}

0 comments on commit ea98599

Please sign in to comment.