This repository has been archived by the owner on Jul 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite some of the pocket upgrade system
Wireless modems now have a special upgrade object. This still uses an upgrade id of 0 and is not registered for crafting. However we elusively use upgrade methods now, and so avoid some special handling for them. This means things like the PocketAPIExtensions class does not need special support for modems too.
- Loading branch information
Showing
8 changed files
with
122 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/org/squiddev/cctweaks/pocket/PocketModem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.squiddev.cctweaks.pocket; | ||
|
||
import dan200.computercraft.api.peripheral.IPeripheral; | ||
import dan200.computercraft.shared.peripheral.PeripheralType; | ||
import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory; | ||
import dan200.computercraft.shared.pocket.peripherals.PocketModemPeripheral; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.world.World; | ||
import org.squiddev.cctweaks.CCTweaks; | ||
import org.squiddev.cctweaks.api.pocket.IPocketAccess; | ||
import org.squiddev.cctweaks.api.pocket.IPocketUpgrade; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class PocketModem implements IPocketUpgrade { | ||
public static final PocketModem INSTANCE = new PocketModem(); | ||
|
||
private PocketModem() { | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public ResourceLocation getUpgradeID() { | ||
return new ResourceLocation(CCTweaks.RESOURCE_DOMAIN, "modem"); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getUnlocalisedAdjective() { | ||
return "upgrade.computercraft:wireless_modem.adjective"; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public ItemStack getCraftingItem() { | ||
return PeripheralItemFactory.create(PeripheralType.WirelessModem, null, 1); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public IPeripheral createPeripheral(@Nonnull IPocketAccess access) { | ||
return new PocketModemPeripheral(false); | ||
} | ||
|
||
@Override | ||
public void update(@Nonnull IPocketAccess access, @Nullable IPeripheral peripheral) { | ||
if (peripheral instanceof PocketModemPeripheral) { | ||
Entity entity = access.getEntity(); | ||
|
||
PocketModemPeripheral modem = (PocketModemPeripheral) peripheral; | ||
if (entity instanceof EntityLivingBase) { | ||
EntityLivingBase player = (EntityLivingBase) entity; | ||
modem.setLocation(entity.getEntityWorld(), player.posX, player.posY + player.getEyeHeight(), player.posZ); | ||
} else if (entity != null) { | ||
modem.setLocation(entity.getEntityWorld(), entity.posX, entity.posY, entity.posZ); | ||
} | ||
|
||
access.setModemLight(modem.isActive()); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onRightClick(@Nonnull World world, @Nonnull IPocketAccess access, @Nullable IPeripheral peripheral) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters