Skip to content

Commit

Permalink
Right-clicking the Meteor Tracker now shows the distance to the close…
Browse files Browse the repository at this point in the history
…st meteor.
  • Loading branch information
MartinSVK12 committed Feb 1, 2024
1 parent 90a5b11 commit b8e0fa0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package sunsetsatellite.signalindustries.items;

import net.minecraft.client.Minecraft;
import net.minecraft.client.render.dynamictexture.DynamicTexture;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.net.command.TextFormatting;
import net.minecraft.core.world.World;
import net.minecraft.core.world.chunk.ChunkCoordinates;
import sunsetsatellite.catalyst.core.util.ICustomDescription;
import sunsetsatellite.signalindustries.SignalIndustries;
import turniplabs.halplibe.helper.TextureHelper;

import static java.lang.Math.PI;

public class ItemMeteorTracker extends Item implements ICustomDescription {


Expand All @@ -29,6 +34,21 @@ public int getIconFromDamage(int id) {
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
if(itemstack.getMetadata() == 0){
itemstack.setMetadata(1);
} else {
ChunkCoordinates chunk = null;
double distance = Double.MAX_VALUE;
Minecraft mc = Minecraft.getMinecraft(this);
for (ChunkCoordinates meteorLocation : SignalIndustries.meteorLocations) {
if(meteorLocation.getSqDistanceTo((int) mc.thePlayer.x, (int) mc.thePlayer.y, (int) mc.thePlayer.z) < distance){
distance = meteorLocation.getSqDistanceTo((int) mc.thePlayer.x, (int) mc.thePlayer.y, (int) mc.thePlayer.z);
chunk = meteorLocation;
}
}
if(chunk != null){
mc.ingameGUI.addChatMessage(String.format("Distance: %.0f blocks",distance));
} else {
mc.ingameGUI.addChatMessage("No meteors detected nearby.");
}
}
return super.onItemRightClick(itemstack, world, entityplayer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public void update() {
double var23 = (double)chunk.x - this.mc.thePlayer.x;
double var25 = (double)chunk.z - this.mc.thePlayer.z;
angle = (double)(this.mc.thePlayer.yRot - 90.0F) * PI / 180.0D - Math.atan2(var25, var23);
if(this.mc.theWorld.dimension == Dimension.nether) {
angle = Math.random() * PI * 2;
}
} else {
return;
}
Expand Down

0 comments on commit b8e0fa0

Please sign in to comment.