Skip to content

Commit

Permalink
Removed unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Sep 24, 2023
1 parent 62b26b3 commit 8a46b1b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import mods.railcraft.util.container.ContainerMapper;
import mods.railcraft.util.container.ContainerTools;
import mods.railcraft.world.entity.RailcraftEntityTypes;
import mods.railcraft.world.inventory.LocomotiveMenu;
import mods.railcraft.world.inventory.RailcraftMenuTypes;
import mods.railcraft.world.inventory.CreativeLocomotiveMenu;
import mods.railcraft.world.item.RailcraftItems;
import mods.railcraft.world.item.TicketItem;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -72,7 +71,7 @@ public int retrieveFuel() {
}

@Override
public Item getItem() {
public Item getDropItem() {
return RailcraftItems.CREATIVE_LOCOMOTIVE.get();
}

Expand Down Expand Up @@ -121,7 +120,6 @@ public boolean needsFuel() {

@Override
protected AbstractContainerMenu createMenu(int id, Inventory playerInventory) {
return new LocomotiveMenu<>(RailcraftMenuTypes.CREATIVE_LOCOMOTIVE.get(), id,
playerInventory, this);
return new CreativeLocomotiveMenu(id, playerInventory, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public int retrieveFuel() {
}

@Override
public Item getItem() {
public Item getDropItem() {
return RailcraftItems.ELECTRIC_LOCOMOTIVE.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,6 @@ private float getNewWhistlePitch() {
return 1f + (float) this.random.nextGaussian() * 0.2f;
}

/**
* Returns the cart's actual item.
*/
protected abstract Item getItem();

@Override
public Item getDropItem() {
return getItem();
}

@Override
public void destroy(DamageSource source) {
this.kill();
Expand All @@ -218,7 +208,7 @@ public void destroy(DamageSource source) {

@Override
public ItemStack getPickResult() {
ItemStack itemStack = this.getItem().getDefaultInstance();
ItemStack itemStack = this.getDropItem().getDefaultInstance();
if (this.isLocked()) {
LocomotiveItem.setOwnerData(itemStack, this.getOwnerOrThrow());
}
Expand Down Expand Up @@ -249,7 +239,7 @@ public InteractionResult interact(Player player, InteractionHand hand) {
return InteractionResult.CONSUME;
}
if (this.canControl(player)) {
super.interact(player, hand); // open gui
super.interact(player, hand);
}
return InteractionResult.CONSUME;
}
Expand Down Expand Up @@ -315,13 +305,6 @@ public void setEmblem(@Nullable String emblem) {
}
}

/**
* Gets the destination ticket item.
*/
public ItemStack getDestItem() {
return ticketContainer().getItem(1);
}

@Override
public String getDestination() {
return this.getEntityData().get(DESTINATION);
Expand Down Expand Up @@ -587,9 +570,9 @@ protected void applyNaturalSlowdown() {

if (speed != Speed.MAX) {
float limit = switch (speed) {
case SLOWEST -> limit = 0.1F;
case SLOWER -> limit = 0.2F;
case NORMAL -> limit = 0.3F;
case SLOWEST -> 0.1F;
case SLOWER -> 0.2F;
case NORMAL -> 0.3F;
default -> 0.4F;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected AbstractContainerMenu createMenu(int id, Inventory playerInventory) {
}

@Override
public Item getItem() {
public Item getDropItem() {
return RailcraftItems.STEAM_LOCOMOTIVE.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package mods.railcraft.world.inventory;

import mods.railcraft.world.entity.vehicle.locomotive.CreativeLocomotive;
import net.minecraft.world.entity.player.Inventory;

public class CreativeLocomotiveMenu extends LocomotiveMenu<CreativeLocomotive> {

public CreativeLocomotiveMenu(int id, Inventory playerInv, CreativeLocomotive loco) {
super(RailcraftMenuTypes.CREATIVE_LOCOMOTIVE.get(), id, playerInv, loco);
}
}
10 changes: 4 additions & 6 deletions src/main/java/mods/railcraft/world/item/CrowbarHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import mods.railcraft.world.entity.vehicle.MinecartUtil;
import mods.railcraft.world.entity.vehicle.SeasonalCart;
import mods.railcraft.world.entity.vehicle.TrackRemover;
import mods.railcraft.world.entity.vehicle.TunnelBore;
import mods.railcraft.world.item.enchantment.RailcraftEnchantments;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
Expand All @@ -34,7 +33,7 @@ public class CrowbarHandler {

public InteractionResult handleInteract(AbstractMinecart cart, Player player,
InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
var stack = player.getItemInHand(hand);
if (stack.isEmpty() || !(stack.getItem() instanceof Crowbar crowbar)) {
return InteractionResult.PASS;
}
Expand Down Expand Up @@ -104,10 +103,9 @@ private void boostCart(Player player, InteractionHand hand, ItemStack stack,
player.causeFoodExhaustion(.25F);

if (player.getVehicle() != null) {
// NOOP
} else if (cart instanceof TunnelBore) {
// NOOP
} else if (cart instanceof Directional directional) {
return;
}
if (cart instanceof Directional directional) {
directional.reverse();
} else if (cart instanceof TrackRemover trackRemover) {
trackRemover.setMode(trackRemover.mode().next());
Expand Down

0 comments on commit 8a46b1b

Please sign in to comment.