Skip to content

Commit

Permalink
add placeholder recipe for GTCEU converter
Browse files Browse the repository at this point in the history
  • Loading branch information
yor42 committed Nov 18, 2024
1 parent 082f699 commit b598609
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 133 deletions.
41 changes: 21 additions & 20 deletions src/main/java/cn/academy/item/MediaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,31 @@ public MediaItem()
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote)
{
MediaAcquireData acquireData = MediaAcquireData.apply(player);
TerminalData tData = TerminalData.get(player);
if (world.isRemote) {
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}

Media media = getMedia(stack.getItemDamage());
MediaAcquireData acquireData = MediaAcquireData.apply(player);
TerminalData tData = TerminalData.get(player);

if (!tData.isInstalled(MediaApp$.MODULE$))
{
player.sendMessage(new TextComponentTranslation("ac.media.notinstalled"));
}
else if (acquireData.isInstalled(media))
{
player.sendMessage(new TextComponentTranslation("ac.media.haveone", media.name()));
}
else
Media media = getMedia(stack.getItemDamage());

if (!tData.isInstalled(MediaApp$.MODULE$))
{
player.sendMessage(new TextComponentTranslation("ac.media.notinstalled"));
}
else if (acquireData.isInstalled(media))
{
player.sendMessage(new TextComponentTranslation("ac.media.haveone", media.name()));
}
else
{
acquireData.install(media);
if (!player.capabilities.isCreativeMode)
{
acquireData.install(media);
if (!player.capabilities.isCreativeMode)
{
stack.shrink(1);
}
player.sendMessage(new TextComponentTranslation("ac.media.acquired", media.name()));
stack.shrink(1);
}
player.sendMessage(new TextComponentTranslation("ac.media.acquired", media.name()));
}

return new ActionResult<>(EnumActionResult.SUCCESS, stack);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/cn/academy/support/gtceu/GTEUSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

import static gregtech.common.blocks.MetaBlocks.MACHINE_CASING;
import static gregtech.common.items.MetaItems.POWER_UNIT_LV;

public class GTEUSupport {

public static final String GTCEU_MODID = "gregtech";
Expand Down Expand Up @@ -49,15 +52,14 @@ public static void init(FMLInitializationEvent event){
EnergyBlockHelper.register(new GTEUSinkManager());
EnergyBlockHelper.register(new GTEUSourceManager());

// https://github.com/TinyModularThings/IC2Classic/blob/master/src/main/java/ic2/api/item/IC2Items.java
GameRegistry.addShapedRecipe(new ResourceLocation("academy","gteu_input"), null,
new ItemStack(gteuInput), "abc", " d ",
'a', ACItems.energy_unit, 'b', ACBlocks.machine_frame,
'c', IC2Items.getItem("cable", "type:copper,insulation:1"), 'd', ACItems.energy_convert_component);
'c', POWER_UNIT_LV, 'd', ACItems.energy_convert_component);
GameRegistry.addShapedRecipe(new ResourceLocation("academy","gteu_output"), null,
new ItemStack(gteuOutput), "abc", " d ",
'a', IC2Items.getItemAPI().getItemStack("te", "batbox"), 'b', ACBlocks.machine_frame,
'c', IC2Items.getItem("cable", "type:copper,insulation:1"), 'd', ACItems.energy_convert_component);
'a', MACHINE_CASING, 'b', ACBlocks.machine_frame,
'c', POWER_UNIT_LV, 'd', ACItems.energy_convert_component);

GameRegistry.addShapedRecipe(new ResourceLocation("academy","gteu_input_output"), null,
new ItemStack(gteuInput),"X",'X',new ItemStack(gteuOutput));
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/cn/academy/support/rf/TileRFOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,22 @@ public TileRFOutput() {
public void update() {
super.update();
World world = getWorld();
if(!world.isRemote) {
for(EnumFacing dir : EnumFacing.VALUES) {
BlockPos pos = this.pos.add(dir.getDirectionVec());
TileEntity te = world.getTileEntity(pos);
if(te instanceof IEnergyStorage && energy > 0) {
IEnergyStorage receiver = (IEnergyStorage) te;
if(receiver.canReceive()) {
int req = receiver.getMaxEnergyStored() - receiver.getEnergyStored();
req = Math.min(if2rf(energy), req);
energy -= rf2if(receiver.receiveEnergy(req, false));
}
}
if (world.isRemote) {
return;
}
for(EnumFacing dir : EnumFacing.VALUES) {
BlockPos pos = this.pos.add(dir.getDirectionVec());
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof IEnergyStorage) || !(energy > 0)) {
continue;
}
IEnergyStorage receiver = (IEnergyStorage) te;
if (!receiver.canReceive()) {
continue;
}
int req = receiver.getMaxEnergyStored() - receiver.getEnergyStored();
req = Math.min(if2rf(energy), req);
energy -= rf2if(receiver.receiveEnergy(req, false));
}
}

Expand Down
Loading

0 comments on commit b598609

Please sign in to comment.