1.17: TechReborn compiles and runs, big thanks to @petabyteboy

Co-authored-by: Milan Pässler <milan@petabyte.dev>
This commit is contained in:
modmuss50 2021-05-29 13:19:29 +01:00
parent c661de5254
commit b33f4be5f4
212 changed files with 952 additions and 2025 deletions

View file

@ -98,7 +98,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
}
private void insertOrDropStack(PlayerEntity playerEntity, ItemStack stack) {
if (!playerEntity.inventory.insertStack(stack)) {
if (!playerEntity.getInventory().insertStack(stack)) {
playerEntity.dropStack(stack);
}
}
@ -184,8 +184,9 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
if (world.canPlayerModifyAt(player, hitPos) && player.canPlaceOn(placePos, side, stack)) {
if (containedFluid == Fluids.EMPTY) {
if (hitState.getBlock() instanceof FluidDrainable) {
Fluid drainFluid = ((FluidDrainable) hitState.getBlock()).tryDrainFluid(world, hitPos, hitState);
if (drainFluid != Fluids.EMPTY) {
ItemStack itemStack = ((FluidDrainable) hitState.getBlock()).tryDrainFluid(world, hitPos, hitState);
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemFluidInfo) {
Fluid drainFluid = ((ItemFluidInfo) itemStack.getItem()).getFluid(itemStack);
if (stack.getCount() == 1) {
stack = getCellWithFluid(drainFluid, 1);
} else {

View file

@ -33,7 +33,7 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ArmorTickable;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemUtils;
import team.reborn.energy.Energy;
@ -45,7 +45,7 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRArmorMaterials;
import techreborn.utils.InitUtils;
public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, ArmorTickable, ArmorRemoveHandler {
public class CloakingDeviceItem extends TRArmourItem implements EnergyHolder, ArmorBlockEntityTicker, ArmorRemoveHandler {
public static int maxCharge = TechRebornConfig.cloakingDeviceCharge;
public static int cost = TechRebornConfig.cloackingDeviceCost;

View file

@ -41,7 +41,7 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ArmorTickable;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.api.items.ItemStackModifiers;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.ItemUtils;
@ -52,7 +52,7 @@ import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.utils.InitUtils;
public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, ArmorTickable, ArmorRemoveHandler, EnergyHolder {
public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, ArmorBlockEntityTicker, ArmorRemoveHandler, EnergyHolder {
public final double flyCost = TechRebornConfig.quantumSuitFlyingCost;
public final double swimCost = TechRebornConfig.quantumSuitSwimmingCost;
@ -60,10 +60,6 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
public final double sprintingCost = TechRebornConfig.quantumSuitSprintingCost;
public final double fireExtinguishCost = TechRebornConfig.fireExtinguishCost;
public final boolean enableSprint = TechRebornConfig.quantumSuitEnableSprint;
public final boolean enableFlight = TechRebornConfig.quantumSuitEnableFlight;
public QuantumSuitItem(ArmorMaterial material, EquipmentSlot slot) {
super(material, slot, new Item.Settings().group(TechReborn.ITEMGROUP).maxDamage(-1).maxCount(1));
}
@ -72,7 +68,7 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
public void getAttributeModifiers(EquipmentSlot equipmentSlot, ItemStack stack, Multimap<EntityAttribute, EntityAttributeModifier> attributes) {
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) {
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS) {
if (Energy.of(stack).getEnergy() > sprintingCost) {
attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
}
@ -95,24 +91,22 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
}
break;
case CHEST:
if (enableFlight){
if (Energy.of(stack).getEnergy() > flyCost && !TechReborn.elytraPredicate.test(playerEntity)) {
playerEntity.abilities.allowFlying = true;
if (playerEntity.abilities.flying) {
Energy.of(stack).use(flyCost);
}
playerEntity.setOnGround(true);
} else {
playerEntity.abilities.allowFlying = false;
playerEntity.abilities.flying = false;
if (Energy.of(stack).getEnergy() > flyCost && !TechReborn.elytraPredicate.test(playerEntity)) {
playerEntity.getAbilities().allowFlying = true;
if (playerEntity.getAbilities().flying) {
Energy.of(stack).use(flyCost);
}
playerEntity.setOnGround(true);
} else {
playerEntity.getAbilities().allowFlying = false;
playerEntity.getAbilities().flying = false;
}
if (playerEntity.isOnFire() && Energy.of(stack).getEnergy() > fireExtinguishCost) {
playerEntity.extinguish();
}
break;
case LEGS:
if (playerEntity.isSprinting() && enableSprint) {
if (playerEntity.isSprinting()) {
Energy.of(stack).use(sprintingCost);
}
break;
@ -135,10 +129,10 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
@Override
public void onRemoved(PlayerEntity playerEntity) {
if (this.slot == EquipmentSlot.CHEST && enableFlight) {
if (this.slot == EquipmentSlot.CHEST) {
if (!playerEntity.isCreative() && !playerEntity.isSpectator()) {
playerEntity.abilities.allowFlying = false;
playerEntity.abilities.flying = false;
playerEntity.getAbilities().allowFlying = false;
playerEntity.getAbilities().flying = false;
}
}
}

View file

@ -68,7 +68,7 @@ public class ChainsawItem extends AxeItem implements EnergyHolder, ItemDurabilit
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (Energy.of(stack).getEnergy() >= cost
&& (state.getMaterial() == Material.WOOD || state.getMaterial() == Material.NETHER_WOOD)) {
&& (state.getMaterial() == Material.WOOD)) {
return poweredSpeed;
}
return unpoweredSpeed;

View file

@ -27,12 +27,10 @@ package techreborn.items.tool;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.command.BlockDataObject;
import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.state.property.Property;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
@ -61,32 +59,23 @@ public class DebugToolItem extends Item {
return ActionResult.FAIL;
}
sendMessage(context, new LiteralText(getRegistryName(block)));
for (Entry<Property<?>, Comparable<?>> entry : blockState.getEntries().entrySet()) {
sendMessage(context, new LiteralText(getPropertyString(entry)));
}
BlockEntity blockEntity = context.getWorld().getBlockEntity(context.getBlockPos());
if (blockEntity == null) {
return ActionResult.SUCCESS;
if (blockEntity != null) {
sendMessage(context, new LiteralText(getBlockEntityType(blockEntity)));
if (Energy.valid(blockEntity)) {
sendMessage(context, new LiteralText(getRCPower(blockEntity)));
}
}
sendMessage(context, new LiteralText(getBlockEntityType(blockEntity)));
if (Energy.valid(blockEntity)) {
sendMessage(context, new LiteralText(getRCPower(blockEntity)));
}
sendMessage(context, getBlockEntityTags(blockEntity));
return ActionResult.SUCCESS;
}
private void sendMessage(ItemUsageContext context, Text message) {
if (context.getWorld().isClient || context.getPlayer() == null) {
return;
private void sendMessage(ItemUsageContext context, Text string) {
if (!context.getWorld().isClient) {
context.getPlayer().sendSystemMessage(string, Util.NIL_UUID);
}
context.getPlayer().sendSystemMessage(message, Util.NIL_UUID);
}
private String getPropertyString(Entry<Property<?>, Comparable<?>> entryIn) {
@ -113,7 +102,7 @@ public class DebugToolItem extends Item {
private String getBlockEntityType(BlockEntity blockEntity) {
String s = "" + Formatting.GREEN;
s += "Block Entity: ";
s += "Tile Entity: ";
s += Formatting.BLUE;
s += blockEntity.getType().toString();
@ -130,13 +119,4 @@ public class DebugToolItem extends Item {
return s;
}
private Text getBlockEntityTags(BlockEntity blockEntity){
MutableText s = new LiteralText("BlockEntity Tags:").formatted(Formatting.GREEN);
BlockDataObject bdo = new BlockDataObject(blockEntity, blockEntity.getPos());
s.append(bdo.getNbt().toText());
return s;
}
}

View file

@ -93,11 +93,10 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
return true;
}
// More checks to fix #2225
// Pass stack to fix #2348
if (Items.DIAMOND_SHOVEL.getMiningSpeedMultiplier(new ItemStack(Items.DIAMOND_SHOVEL), blockIn) > 1.0f) {
if (Items.DIAMOND_SHOVEL.getMiningSpeedMultiplier(null, blockIn) > 1.0f) {
return true;
}
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(new ItemStack(Items.DIAMOND_SHOVEL), blockIn) > 1.0f;
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(null, blockIn) > 1.0f;
}
// MiningToolItem

View file

@ -57,7 +57,7 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
protected final float unpoweredSpeed = 0.5F;
public JackhammerItem(int energyCapacity, EnergyTier tier, int cost) {
super(ToolMaterials.DIAMOND, (int) ToolMaterials.DIAMOND.getAttackDamage(), 1F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(ToolMaterials.DIAMOND, (int) ToolMaterials.DIAMOND.getAttackDamage(), 1F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
this.maxCharge = energyCapacity;
this.tier = tier;
this.cost = cost;
@ -111,11 +111,6 @@ public class JackhammerItem extends PickaxeItem implements EnergyHolder, ItemDur
}
// Item
@Override
public boolean isDamageable() {
return false;
}
@Override
public boolean isEnchantable(ItemStack stack) {
return true;

View file

@ -55,7 +55,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
// 400k FE with 1k FE\t charge rate
public RockCutterItem() {
super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
}
// PickaxeItem

View file

@ -69,7 +69,7 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
// 4M FE max charge with 1k charge rate
public OmniToolItem() {
super(ToolMaterials.DIAMOND, 3, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(ToolMaterials.DIAMOND, 3, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
this.miningLevel = MiningLevel.DIAMOND.intLevel;
}