Fix CC peripherals

This commit is contained in:
Andrew-71 2023-08-03 18:07:34 +03:00
parent 4c6939e69f
commit b264703521
17 changed files with 189 additions and 138 deletions

View file

@ -1,33 +0,0 @@
package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.tardim.TardimManager;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import static com.swdteam.tardim.tardim.TardimManager.FUEL_MAP;
// This mixin aims to make TARDIM fuel system less awful by allowing users to put standard furnace fuel into it.
@Mixin(value = TardimManager.class, remap = false)
public class BetterFuelMapMixin {
@Overwrite
public static boolean isFuel(Item i) {
return FUEL_MAP.containsKey(i) || AbstractFurnaceBlockEntity.getFuel().containsKey(i);
}
@Overwrite
public static double getFuel(Item i) {
if (!isFuel(i)) {
return 0.0;
}
if (!AbstractFurnaceBlockEntity.getFuel().containsKey(i)) {
return (Double)FUEL_MAP.get(i);
}
else
return AbstractFurnaceBlockEntity.getFuel().get(i) / 8000.0; // Adapt with coal's 1600 ticks -> 0.2 fuel
}
}

View file

@ -1,50 +0,0 @@
package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.common.block.BlockFuelStorage;
import com.swdteam.tardim.common.init.TRDDimensions;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HopperBlock;
import net.minecraft.world.level.block.entity.HopperBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import static su.a71.tardim_ic.Constants.LOG;
@Mixin(value = TileEntityFuelStorage.class, remap = false)
public class BetterFuelStorageMixin {
// This is rather inefficient as we iterate 2 times
// However, the hoppers are so small and this method is called so rarely that it should be fine.
@Inject(method = "serverTick(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lcom/swdteam/tardim/tileentity/TileEntityFuelStorage;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/HopperBlockEntity;removeItem(II)Lnet/minecraft/world/item/ItemStack;"),
locals = LocalCapture.CAPTURE_FAILHARD)
private static void saveLavaBuckets(Level world, BlockPos pos, BlockState state, TileEntityFuelStorage blockEntity, CallbackInfo ci) {
HopperBlockEntity mixin_hopper = (HopperBlockEntity)world.getBlockEntity(blockEntity.getBlockPos().above());
for(int j = 0; j < mixin_hopper.getContainerSize(); ++j) {
ItemStack stack = mixin_hopper.getItem(j);
double fuel = TardimManager.getFuel(stack.getItem());
if (fuel > 0.0) {
if (stack.getItem() instanceof BucketItem) {
LOG.info("THIS IS A BUCKET");
mixin_hopper.setItem(j, new ItemStack(stack.getItem().getCraftingRemainingItem(), 2));
} else {
mixin_hopper.removeItem(j, 1);
}
}
}
}
}

View file

@ -1,58 +1,58 @@
package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.common.command.tardim.CommandLocate;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse;
@Mixin(value = CommandLocate.class, remap = false)
public class JammerMixin {
// @Inject(method="execute()V", at=@At(value = "INVOKE",
// target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
// public void execute(CallbackInfo ci) {
// LOG.info("test");
//// for (ItemStack armour : player.getArmorSlots()) {
//// if (armour.is(LOCATION_JAMMER)) {
//// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source);
//// ci.cancel();
//// };
//// }
//package su.a71.tardim_ic.mixin;
//
//import com.swdteam.tardim.common.command.tardim.CommandLocate;
//import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
//import com.swdteam.tardim.tardim.TardimData;
//import com.swdteam.tardim.tardim.TardimManager;
//import net.minecraft.core.BlockPos;
//import net.minecraft.world.entity.player.Player;
//import net.minecraft.world.item.ItemStack;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.Overwrite;
//
//import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse;
//
//@Mixin(value = CommandLocate.class, remap = false)
//public class JammerMixin {
//// @Inject(method="execute()V", at=@At(value = "INVOKE",
//// target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
//// public void execute(CallbackInfo ci) {
//// LOG.info("test");
////// for (ItemStack armour : player.getArmorSlots()) {
////// if (armour.is(LOCATION_JAMMER)) {
////// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source);
////// ci.cancel();
////// };
////// }
//// }
//
// @Overwrite
// public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
// if (args.length == 1) {
// TardimData data = TardimManager.getFromPos(pos);
// if (data != null) {
// if (data.hasPermission(player)) {
// Player otherPlayer = player.getServer().getPlayerList().getPlayerByName(args[0]);
// if (otherPlayer != null) {
// for (ItemStack armour : otherPlayer.getArmorSlots()) {
//// if (armour.is(PERSONAL_JAMMER)) {
//// sendResponse(player, otherPlayer.getGameProfile().getName() + "'s location is jammed", CommandTardimBase.ResponseType.FAIL, source);
//// return;
//// }
// // TODO: Re-add
// }
// data.setTravelLocation(new TardimData.Location(otherPlayer.blockPosition(), otherPlayer.level().dimension()));
// sendResponse(player, "Coords locked on to " + otherPlayer.getGameProfile().getName(), CommandTardimBase.ResponseType.COMPLETE, source);
// } else {
// sendResponse(player, "Player does not exist", CommandTardimBase.ResponseType.FAIL, source);
// }
// } else {
// sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
// }
// }
// } else {
// sendResponse(player, ((CommandLocate)(Object)this).getUsage(), CommandTardimBase.ResponseType.FAIL, source);
// }
//
// }
@Overwrite
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 1) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
Player otherPlayer = player.getServer().getPlayerList().getPlayerByName(args[0]);
if (otherPlayer != null) {
for (ItemStack armour : otherPlayer.getArmorSlots()) {
// if (armour.is(PERSONAL_JAMMER)) {
// sendResponse(player, otherPlayer.getGameProfile().getName() + "'s location is jammed", CommandTardimBase.ResponseType.FAIL, source);
// return;
// }
// TODO: Re-add
}
data.setTravelLocation(new TardimData.Location(otherPlayer.blockPosition(), otherPlayer.level().dimension()));
sendResponse(player, "Coords locked on to " + otherPlayer.getGameProfile().getName(), CommandTardimBase.ResponseType.COMPLETE, source);
} else {
sendResponse(player, "Player does not exist", CommandTardimBase.ResponseType.FAIL, source);
}
} else {
sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
sendResponse(player, ((CommandLocate)(Object)this).getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
}
//}

View file

@ -2,6 +2,7 @@
"block.tardim_ic.digital_tardim_interface": "Digital TARDIM Interface",
"block.tardim_ic.redstone_tardim_input": "Redstone TARDIM Input",
"block.tardim_ic.tardim_dock": "TARDIM Dock",
"block.tardim_ic.food_machine": "TARDIM food machine",
"itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Cloister bell rings",

View file

@ -2,6 +2,7 @@
"block.tardim_ic.digital_tardim_interface": "Digital TARDIM interface",
"block.tardim_ic.redstone_tardim_input": "Redstone TARDIM input",
"block.tardim_ic.tardim_dock": "TARDIM dock",
"block.tardim_ic.food_machine": "TARDIM food machine",
"itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Cloister bell rings",

View file

@ -2,6 +2,7 @@
"block.tardim_ic.digital_tardim_interface": "Цифровой интерфейс TARDIM",
"block.tardim_ic.redstone_tardim_input": "Редстоуновый ввод TARDIM",
"block.tardim_ic.tardim_dock": "Стыковочная станция для TARDIM",
"block.tardim_ic.food_machine": "Раздатчик еды",
"itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Звон монастырского колокола",