Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroksl committed Aug 23, 2024
1 parent 77ae543 commit 709b518
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 271 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ loader_version_range=[4,)
mod_id=advanced_ae
mod_name=Advanced AE
mod_license=LGPL-3.0
mod_version=0.1-1.21.1
mod_version=0.2-1.21.1
mod_group_id=net.pedroksl.advanced_ae
mod_authors=Pedroksl
mod_description=This mod aims to expand on the added capabilities of Extended AE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@
import appeng.core.definitions.BlockDefinition;

public enum AAECraftingUnitType implements ICraftingUnitType {
UNIT(0, "unit"),
ACCELERATOR(0, "accelerator");

private final int storageMb;
private final String affix;

AAECraftingUnitType(int storageMb, String affix) {
this.storageMb = storageMb;
this.affix = affix;
}

@Override
public long getStorageBytes() {
return 1024L * 1024 * storageMb;
}

@Override
public int getAcceleratorThreads() {
return this == ACCELERATOR ? 4 : 0;
}

public String getAffix() {
return this.affix;
}

public BlockDefinition<?> getDefinition() {
// return switch (this) {
// case UNIT -> AAEBlocks.ADV_CRAFTING_UNIT;
// case ACCELERATOR -> AAEBlocks.ADV_CRAFTING_ACCELERATOR;
// };
return null;
}

@Override
public Item getItemFromType() {
return getDefinition().asItem();
}
UNIT(0, "unit"),
ACCELERATOR(0, "accelerator");

private final int storageMb;
private final String affix;

AAECraftingUnitType(int storageMb, String affix) {
this.storageMb = storageMb;
this.affix = affix;
}

@Override
public long getStorageBytes() {
return 1024L * 1024 * storageMb;
}

@Override
public int getAcceleratorThreads() {
return this == ACCELERATOR ? 4 : 0;
}

public String getAffix() {
return this.affix;
}

public BlockDefinition<?> getDefinition() {
// return switch (this) {
// case UNIT -> AAEBlocks.ADV_CRAFTING_UNIT;
// case ACCELERATOR -> AAEBlocks.ADV_CRAFTING_ACCELERATOR;
// };
return null;
}

@Override
public Item getItemFromType() {
return getDefinition().asItem();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,89 +31,89 @@

public class AdvPatternProviderUpgradeItem extends Item {

public AdvPatternProviderUpgradeItem(Properties properties) {
super(properties);
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Nonnull
@Override
public InteractionResult useOn(@Nonnull UseOnContext context) {
var pos = context.getClickedPos();
var world = context.getLevel();
var entity = world.getBlockEntity(pos);
if (entity != null) {
var ctx = new BlockPlaceContext(context);
var tClazz = entity.getClass();
if (tClazz == PatternProviderBlockEntity.class || tClazz == TileExPatternProvider.class) {

var originState = world.getBlockState(pos);
var isSmall = tClazz == PatternProviderBlockEntity.class;

var state = isSmall
? AAEBlocks.SMALL_ADV_PATTERN_PROVIDER.block().getStateForPlacement(ctx)
: AAEBlocks.ADV_PATTERN_PROVIDER.block().getStateForPlacement(ctx);
if (state == null) {
return InteractionResult.PASS;
}
for (var sp : originState.getValues().entrySet()) {
var pt = sp.getKey();
var va = sp.getValue();
try {
if (state.hasProperty(pt)) {
state = state.<Comparable, Comparable>setValue((Property) pt, va);
}
} catch (Exception ignore) {
// NO-OP
}
}

BlockEntityType<?> tileType = isSmall
? AAEBlockEntities.SMALL_ADV_PATTERN_PROVIDER.get()
: AAEBlockEntities.ADV_PATTERN_PROVIDER.get();
BlockEntity te = tileType.create(pos, state);
FCUtil.replaceTile(world, pos, entity, te, state);
context.getItemInHand().shrink(1);
return InteractionResult.CONSUME;

} else if (entity instanceof CableBusBlockEntity cable) {
Vec3 hitVec = context.getClickLocation();
Vec3 hitInBlock = new Vec3(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
var part = cable.getCableBus().selectPartLocal(hitInBlock).part;
if (part instanceof AEBasePart basePart
&& (part.getClass() == PatternProviderPart.class
|| part.getClass() == PartExPatternProvider.class)) {
var side = basePart.getSide();
var contents = new CompoundTag();

var isSmall = part.getClass() == PatternProviderPart.class;

var partItem =
isSmall ? AAEItems.SMALL_ADV_PATTERN_PROVIDER.get() : AAEItems.ADV_PATTERN_PROVIDER.get();

part.writeToNBT(contents, world.registryAccess());
var p = cable.replacePart(partItem, side, context.getPlayer(), null);
if (p != null) {
p.readFromNBT(contents, world.registryAccess());
}
} else {
return InteractionResult.PASS;
}
context.getItemInHand().shrink(1);
return InteractionResult.sidedSuccess(world.isClientSide);
}
}
return InteractionResult.PASS;
}

@ParametersAreNonnullByDefault
@Override
public void appendHoverText(
ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);

tooltipComponents.add(Component.empty()
.append("§7Upgrades a normal or extended pattern provider to the "
+ "advanced version with the same amount of pattern slots"));
}
public AdvPatternProviderUpgradeItem(Properties properties) {
super(properties);
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Nonnull
@Override
public InteractionResult useOn(@Nonnull UseOnContext context) {
var pos = context.getClickedPos();
var world = context.getLevel();
var entity = world.getBlockEntity(pos);
if (entity != null) {
var ctx = new BlockPlaceContext(context);
var tClazz = entity.getClass();
if (tClazz == PatternProviderBlockEntity.class || tClazz == TileExPatternProvider.class) {

var originState = world.getBlockState(pos);
var isSmall = tClazz == PatternProviderBlockEntity.class;

var state = isSmall
? AAEBlocks.SMALL_ADV_PATTERN_PROVIDER.block().getStateForPlacement(ctx)
: AAEBlocks.ADV_PATTERN_PROVIDER.block().getStateForPlacement(ctx);
if (state == null) {
return InteractionResult.PASS;
}
for (var sp : originState.getValues().entrySet()) {
var pt = sp.getKey();
var va = sp.getValue();
try {
if (state.hasProperty(pt)) {
state = state.<Comparable, Comparable>setValue((Property) pt, va);
}
} catch (Exception ignore) {
// NO-OP
}
}

BlockEntityType<?> tileType = isSmall
? AAEBlockEntities.SMALL_ADV_PATTERN_PROVIDER.get()
: AAEBlockEntities.ADV_PATTERN_PROVIDER.get();
BlockEntity te = tileType.create(pos, state);
FCUtil.replaceTile(world, pos, entity, te, state);
context.getItemInHand().shrink(1);
return InteractionResult.CONSUME;

} else if (entity instanceof CableBusBlockEntity cable) {
Vec3 hitVec = context.getClickLocation();
Vec3 hitInBlock = new Vec3(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
var part = cable.getCableBus().selectPartLocal(hitInBlock).part;
if (part instanceof AEBasePart basePart
&& (part.getClass() == PatternProviderPart.class
|| part.getClass() == PartExPatternProvider.class)) {
var side = basePart.getSide();
var contents = new CompoundTag();

var isSmall = part.getClass() == PatternProviderPart.class;

var partItem =
isSmall ? AAEItems.SMALL_ADV_PATTERN_PROVIDER.get() : AAEItems.ADV_PATTERN_PROVIDER.get();

part.writeToNBT(contents, world.registryAccess());
var p = cable.replacePart(partItem, side, context.getPlayer(), null);
if (p != null) {
p.readFromNBT(contents, world.registryAccess());
}
} else {
return InteractionResult.PASS;
}
context.getItemInHand().shrink(1);
return InteractionResult.sidedSuccess(world.isClientSide);
}
}
return InteractionResult.PASS;
}

@ParametersAreNonnullByDefault
@Override
public void appendHoverText(
ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);

tooltipComponents.add(Component.empty()
.append("§7Upgrades a normal or extended pattern provider to the "
+ "advanced version with the same amount of pattern slots"));
}
}
Loading

0 comments on commit 709b518

Please sign in to comment.