Jump to content

[1.7.2][Solved]Getting all items and checking if player is in void?


Nimbleguy

Recommended Posts

How would I get all items "alive?" I need to check if there are items in the void, then get item info and do stuff with it, but I do not know how to get all EntityItems in the world. I tried this code, but it did not work:

TickListner(Method 1):

 

 

@SubscribeEvent

public void itemDrop(ItemTossEvent e) {

System.out.println("Item Dropped");

if (e.entityItem.dimension == VoidMod.NullVoidDimID) {

System.out.println("In Void");

this.itemDropped = e.entityItem;

System.out.println(itemDropped);

}

}

 

 

TickListner(Method 2):

 

 

@SubscribeEvent

public void onTick(TickEvent.ServerTickEvent event) {

// System.out.println("OnTick");

String[] pls = MinecraftServer.getServer().getConfigurationManager()

.getAllUsernames();

EntityPlayerMP p;

for (int i = 0; i < pls.length; i++) {

p = MinecraftServer.getServer().getConfigurationManager()

.getPlayerForUsername(pls);

if (p != null) {

// System.out.println("Got a ticked player");

if (p.posY <= 0) {

// System.out.println("In the void!");

if (p.dimension == VoidMod.NullVoidDimID) {

p.setLocationAndAngles(p.posX, 256, p.posZ,

p.cameraYaw, p.cameraPitch);

}

p.addStat(VoidMod.fallVoid, 1);

}

if (p.dimension == VoidMod.NullVoidDimID) {

p.clearActivePotions();

}

}

}

World w;

Double x;

Double z;

System.out.println(itemDropped);

if (itemDropped != null) {

System.out.println("Not Null");

if (itemDropped.posY <= 0) {

System.out.println("In Void");

if (itemDropped.getEntityItem().getItem()

.equals(VoidMod.nullVoidAlloy)) {

System.out.println("Is Alloy");

w = itemDropped.worldObj;

x = itemDropped.posX;

z = itemDropped.posZ;

itemDropped.setDead();

itemDropped = null;

w.spawnEntityInWorld(new EntityItem(w, x, 200D, z,

new ItemStack(VoidMod.corruptAlloy)));

}

}

}

 

// WorldProviderNullVoid.getProviderForDimension(VoidMod.NullVoidDimID).setWorldTime(13000);

}

 

 

I am also having trouble with checking if the player has fallen into the void, it is the same code(In method 2) It is giving me the achievement but not teleporting me.

Link to comment
Share on other sites

  if (e.entityItem.dimension == VoidMod.NullVoidDimID)

 

Why are you checking the dimension? The item you need would be in the world where it created...

and you have to edit the teleporting code if you want to teleport the player.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

First how are you getting sent to your dimension.

Second

 p = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(pls);

should be

         p = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(pls[i]);

.

Third

 if (itemDropped.getEntityItem().getItem().equals(VoidMod.nullVoidAlloy))

should be

 if (itemDropped.getEntityItem().getItem() instanceof ItemNullVoidAlloy))

Link to comment
Share on other sites

I do not know why in the code I posted it says str, in my actual code it says str. Also, I have found that equals works in another case. My problem is that it is not recognizing it is in the void. Also I have a block that teleports you into my dimension, but my code is not able to recognize any item past y level 0, which is what I want to do.

Code:

TickListner:

 

 

package aj.Java.Nullvoid.Listners;

 

import java.awt.Color;

import java.util.List;

import java.util.Random;

 

import aj.Java.Nullvoid.VoidMod;

import baubles.api.BaublesApi;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.Potion;

import net.minecraft.potion.PotionEffect;

import net.minecraft.server.MinecraftServer;

import net.minecraft.world.World;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

import net.minecraftforge.client.event.TextureStitchEvent;

import net.minecraftforge.event.entity.item.ItemTossEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

import cpw.mods.fml.common.gameevent.TickEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class TickListner {

private World world;

@SubscribeEvent

public void onTick(TickEvent.ServerTickEvent event) {

// System.out.println("OnTick");

String[] pls = MinecraftServer.getServer().getConfigurationManager()

.getAllUsernames();

EntityPlayerMP p;

for (int i = 0; i < pls.length; i++) {

p = MinecraftServer.getServer().getConfigurationManager()

.getPlayerForUsername(pls);

if (p != null) {

// System.out.println("Got a ticked player");

if (p.posY <= 0) {

// System.out.println("In the void!");

if (p.dimension == VoidMod.NullVoidDimID) {

p.setLocationAndAngles(p.posX, 256, p.posZ,

p.cameraYaw, p.cameraPitch);

}

p.addStat(VoidMod.fallVoid, 1);

}

if (p.dimension == VoidMod.NullVoidDimID) {

if(p.inventory.getCurrentItem() == null){

p.clearActivePotions();

}

else{

if(!p.inventory.getCurrentItem().getItem().equals(VoidMod.baneOfDark)){

p.clearActivePotions();

}

else{

p.addPotionEffect(new PotionEffect(Potion.nightVision.id, 140, 10));

}

}

}

}

}

if(world != null){

@SuppressWarnings("rawtypes")

List l = world.loadedEntityList;

for(int i = 0; i < l.size(); i++){

if(l.get(i) != null){

if(l.get(i) instanceof EntityItem){

System.out.println("Not Null");

EntityItem item = (EntityItem)l.get(i);

if (item.posY <= 0) {

System.out.println("In Void");

if (item.getEntityItem().getItem()

.equals(VoidMod.nullVoidAlloy)) {

System.out.println("Is Alloy");

world.spawnEntityInWorld(new EntityItem(world, item.posX, 200D, item.posZ,

new ItemStack(VoidMod.corruptAlloy)));

}

}

}

}

}

}

 

// WorldProviderNullVoid.getProviderForDimension(VoidMod.NullVoidDimID).setWorldTime(13000);

}

 

@SubscribeEvent

@SideOnly(Side.CLIENT)

public void clientTick(TickEvent.ClientTickEvent event) {

if (Minecraft.getMinecraft().thePlayer != null) {

if (Minecraft.getMinecraft().thePlayer.dimension == VoidMod.NullVoidDimID) {

if(Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() != null){

if(Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getItem().equals(VoidMod.baneOfDark)){

Minecraft.getMinecraft().gameSettings.gammaSetting = 1F;

}

else{

Minecraft.getMinecraft().gameSettings.gammaSetting = -1F;

}

}

else{

Minecraft.getMinecraft().gameSettings.gammaSetting = -1F;

}

} else {

if (Minecraft.getMinecraft().gameSettings.gammaSetting == -1F) {

Minecraft.getMinecraft().gameSettings.gammaSetting = Minecraft

.getMinecraft().thePlayer.getEntityData().getFloat(

"NullGamma");

}

}

}

}

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void texturePreStitch(TextureStitchEvent.Pre event) {

if (event.map.getTextureType() == 0) {

event.map.setTextureEntry("nullvoid:nullOre", VoidMod.texNullOre);

}

}

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void renderGlitch(RenderGameOverlayEvent event) {

if (VoidMod.glitchAmulet != null

&& Minecraft.getMinecraft().thePlayer != null) {

if (BaublesApi.getBaubles(Minecraft.getMinecraft().thePlayer)

.getStackInSlot(0) != null) {

if (!BaublesApi.getBaubles(Minecraft.getMinecraft().thePlayer)

.getStackInSlot(0)

.isItemEqual(new ItemStack(VoidMod.glitchAmulet))) {

glitch();

}

} else {

glitch();

}

}

}

 

@SubscribeEvent

public void crafted(ItemCraftedEvent event) {

if (event.crafting.getItem().equals(VoidMod.nullGoggles)) {

event.player.addStat(VoidMod.craftGoggle, 1);

}

}

 

@SubscribeEvent

public void itemDrop(ItemTossEvent e) {

System.out.println("Item Dropped");

if (e.entityItem.dimension == VoidMod.NullVoidDimID) {

System.out.println("In Void");

this.world = e.entityItem.worldObj;

}

}

 

private String getLetter() {

switch (new Random().nextInt(26)) {

case 0:

return "A";

case 1:

return "B";

case 2:

return "C";

case 3:

return "D";

case 4:

return "E";

case 5:

return "F";

case 6:

return "G";

case 7:

return "H";

case 8:

return "I";

case 9:

return "J";

case 10:

return "K";

case 11:

return "L";

case 12:

return "M";

case 13:

return "N";

case 14:

return "O";

case 15:

return "P";

case 16:

return "Q";

case 17:

return "R";

case 18:

return "S";

case 19:

return "T";

case 20:

return "U";

case 21:

return "V";

case 22:

return "W";

case 23:

return "X";

case 24:

return "Y";

case 25:

return "Z";

}

return null;

}

 

private void glitch() {

if (Minecraft.getMinecraft().thePlayer.dimension == VoidMod.NullVoidDimID) {

if (Minecraft.getMinecraft().thePlayer.posX < 10

&& Minecraft.getMinecraft().thePlayer.posX > -10

&& Minecraft.getMinecraft().thePlayer.posZ < 10

&& Minecraft.getMinecraft().thePlayer.posZ > -10) {

for (int i = 0; i < 10000; i++) {

Minecraft.getMinecraft().fontRenderer

.drawString(getLetter(),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(),

new Random().nextFloat()).getRGB());

}

} else if (Minecraft.getMinecraft().thePlayer.posX < 50

&& Minecraft.getMinecraft().thePlayer.posX > -50

&& Minecraft.getMinecraft().thePlayer.posZ < 50

&& Minecraft.getMinecraft().thePlayer.posZ > -50) {

for (int i = 0; i < 1000; i++) {

Minecraft.getMinecraft().fontRenderer

.drawString(getLetter(),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(),

new Random().nextFloat()).getRGB());

}

} else if (Minecraft.getMinecraft().thePlayer.posX < 100

&& Minecraft.getMinecraft().thePlayer.posX > -100

&& Minecraft.getMinecraft().thePlayer.posZ < 100

&& Minecraft.getMinecraft().thePlayer.posZ > -100) {

for (int i = 0; i < 100; i++) {

Minecraft.getMinecraft().fontRenderer

.drawString(getLetter(),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(),

new Random().nextFloat()).getRGB());

}

} else {

Minecraft.getMinecraft().fontRenderer

.drawString(

getLetter(),

new Random().nextInt(Minecraft.getMinecraft().displayWidth),

new Random().nextInt(Minecraft.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(), new Random()

.nextFloat()).getRGB());

}

}

}

}

 

 

Link to comment
Share on other sites

The tick listener is registered in both event bus things, and I am trying to teleport the item to x 256 in the dimension if they are in the dimension and under y 0. I have a separate method for getting in the dimension. I think I have a problem with getting the world, because there are no entries in world.loadedEntityList and the player one is detecting properly.

Link to comment
Share on other sites

Ok then. I just solved it by looping through all the worlds in MinecraftServer.getServer().worldServers and using those.

TickListner:

 

 

package aj.Java.Nullvoid.Listners;

 

import java.awt.Color;

import java.util.List;

import java.util.Random;

 

import aj.Java.Nullvoid.VoidMod;

import baubles.api.BaublesApi;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.item.ItemStack;

import net.minecraft.server.MinecraftServer;

import net.minecraft.world.World;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

import net.minecraftforge.client.event.TextureStitchEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

import cpw.mods.fml.common.gameevent.TickEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class TickListner {

@SubscribeEvent

public void onTick(TickEvent.ServerTickEvent event) {

// System.out.println("OnTick");

String[] pls = MinecraftServer.getServer().getConfigurationManager()

.getAllUsernames();

EntityPlayerMP p;

for (int i = 0; i < pls.length; i++) {

p = MinecraftServer.getServer().getConfigurationManager()

.getPlayerForUsername(pls);

if (p != null) {

// System.out.println("Got a ticked player");

// System.out.println(p.posY);

if (p.posY < 0.01D) {

System.out.println("In the void!");

if (p.dimension == VoidMod.NullVoidDimID) {

p.setLocationAndAngles(p.posX, 256, p.posZ,

p.cameraYaw, p.cameraPitch);

}

p.addStat(VoidMod.fallVoid, 1);

}

if (p.dimension == VoidMod.NullVoidDimID) {

if (p.inventory.getCurrentItem() == null) {

p.clearActivePotions();

}

}

}

}

World world;

for (int ii = 0; ii < MinecraftServer.getServer().worldServers.length; ii++) {

world = MinecraftServer.getServer().worldServers[ii];

if (world != null) {

@SuppressWarnings("rawtypes")

List l = world.loadedEntityList;

for (int i = 0; i < l.size(); i++) {

if (l.get(i) != null) {

if (l.get(i) instanceof EntityItem) {

System.out.println("Not Null");

EntityItem item = (EntityItem) l.get(i);

if (item.posY < 1D) {

System.out.println("In Void");

if (item.getEntityItem().getItem()

.equals(VoidMod.nullVoidAlloy)) {

System.out.println("Is Alloy");

world.spawnEntityInWorld(new EntityItem(

world, item.posX, 200D, item.posZ,

new ItemStack(VoidMod.corruptAlloy, 1)));

}

}

}

}

}

}

}

 

// WorldProviderNullVoid.getProviderForDimension(VoidMod.NullVoidDimID).setWorldTime(13000);

}

 

@SubscribeEvent

@SideOnly(Side.CLIENT)

public void clientTick(TickEvent.ClientTickEvent event) {

if (Minecraft.getMinecraft().thePlayer != null) {

if (Minecraft.getMinecraft().thePlayer.dimension == VoidMod.NullVoidDimID) {

if (Minecraft.getMinecraft().thePlayer.inventory

.getCurrentItem() != null) {

if (Minecraft.getMinecraft().thePlayer.inventory

.getCurrentItem().getItem()

.equals(VoidMod.baneOfDark)) {

Minecraft.getMinecraft().gameSettings.gammaSetting = 1F;

} else {

Minecraft.getMinecraft().gameSettings.gammaSetting = -1F;

}

} else {

Minecraft.getMinecraft().gameSettings.gammaSetting = -1F;

}

} else {

if (Minecraft.getMinecraft().gameSettings.gammaSetting == -1F) {

Minecraft.getMinecraft().gameSettings.gammaSetting = Minecraft

.getMinecraft().thePlayer.getEntityData().getFloat(

"NullGamma");

}

}

}

}

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void texturePreStitch(TextureStitchEvent.Pre event) {

if (event.map.getTextureType() == 0) {

event.map.setTextureEntry("nullvoid:nullOre", VoidMod.texNullOre);

}

}

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void renderGlitch(RenderGameOverlayEvent event) {

if (VoidMod.glitchAmulet != null

&& Minecraft.getMinecraft().thePlayer != null) {

if (BaublesApi.getBaubles(Minecraft.getMinecraft().thePlayer)

.getStackInSlot(0) != null) {

if (!BaublesApi.getBaubles(Minecraft.getMinecraft().thePlayer)

.getStackInSlot(0)

.isItemEqual(new ItemStack(VoidMod.glitchAmulet))) {

glitch();

}

} else {

glitch();

}

}

}

 

@SubscribeEvent

public void crafted(ItemCraftedEvent event) {

if (event.crafting.getItem().equals(VoidMod.nullGoggles)) {

event.player.addStat(VoidMod.craftGoggle, 1);

}

}

 

private String getLetter() {

switch (new Random().nextInt(26)) {

case 0:

return "A";

case 1:

return "B";

case 2:

return "C";

case 3:

return "D";

case 4:

return "E";

case 5:

return "F";

case 6:

return "G";

case 7:

return "H";

case 8:

return "I";

case 9:

return "J";

case 10:

return "K";

case 11:

return "L";

case 12:

return "M";

case 13:

return "N";

case 14:

return "O";

case 15:

return "P";

case 16:

return "Q";

case 17:

return "R";

case 18:

return "S";

case 19:

return "T";

case 20:

return "U";

case 21:

return "V";

case 22:

return "W";

case 23:

return "X";

case 24:

return "Y";

case 25:

return "Z";

}

return null;

}

 

private void glitch() {

if (Minecraft.getMinecraft().thePlayer.dimension == VoidMod.NullVoidDimID) {

if (Minecraft.getMinecraft().thePlayer.posX < 10

&& Minecraft.getMinecraft().thePlayer.posX > -10

&& Minecraft.getMinecraft().thePlayer.posZ < 10

&& Minecraft.getMinecraft().thePlayer.posZ > -10) {

for (int i = 0; i < 10000; i++) {

Minecraft.getMinecraft().fontRenderer

.drawString(getLetter(),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(),

new Random().nextFloat()).getRGB());

}

} else if (Minecraft.getMinecraft().thePlayer.posX < 50

&& Minecraft.getMinecraft().thePlayer.posX > -50

&& Minecraft.getMinecraft().thePlayer.posZ < 50

&& Minecraft.getMinecraft().thePlayer.posZ > -50) {

for (int i = 0; i < 1000; i++) {

Minecraft.getMinecraft().fontRenderer

.drawString(getLetter(),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(),

new Random().nextFloat()).getRGB());

}

} else if (Minecraft.getMinecraft().thePlayer.posX < 100

&& Minecraft.getMinecraft().thePlayer.posX > -100

&& Minecraft.getMinecraft().thePlayer.posZ < 100

&& Minecraft.getMinecraft().thePlayer.posZ > -100) {

for (int i = 0; i < 100; i++) {

Minecraft.getMinecraft().fontRenderer

.drawString(getLetter(),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Random().nextInt(Minecraft

.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(),

new Random().nextFloat()).getRGB());

}

} else {

Minecraft.getMinecraft().fontRenderer

.drawString(

getLetter(),

new Random().nextInt(Minecraft.getMinecraft().displayWidth),

new Random().nextInt(Minecraft.getMinecraft().displayWidth),

new Color(new Random().nextFloat(),

new Random().nextFloat(), new Random()

.nextFloat()).getRGB());

}

}

}

}

 

 

Link to comment
Share on other sites

Ok, I edited to your comments, but I need to set the player's gamma to one previously set, and I want to to retain across minecraft closings. How would I do that? I think packets but I do not know how to use them at all. Thanks for helping me fix my code :).

Revised TickListner:

 

 

package aj.Java.Nullvoid.Listners;

 

import java.awt.Color;

import java.util.Random;

 

import aj.Java.Nullvoid.VoidMod;

import baubles.api.BaublesApi;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

import net.minecraftforge.client.event.TextureStitchEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

import cpw.mods.fml.common.gameevent.TickEvent;

import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class TickListner {

private Minecraft m = Minecraft.getMinecraft();

private Random r = new Random();

@SubscribeEvent

public void playerTick(PlayerTickEvent event){

EntityPlayer p = event.player;

if (p != null) {

// System.out.println("Got a ticked player");

// System.out.println(p.posY);

if (p.posY < 0.01D) {

System.out.println("In the void!");

if (p.dimension == VoidMod.NullVoidDimID) {

p.setLocationAndAngles(p.posX, 256, p.posZ,

p.cameraYaw, p.cameraPitch);

}

p.addStat(VoidMod.fallVoid, 1);

}

if (p.dimension == VoidMod.NullVoidDimID) {

if (p.inventory.getCurrentItem() == null) {

p.clearActivePotions();

}

}

}

}

 

@SubscribeEvent

@SideOnly(Side.CLIENT)

public void clientTick(TickEvent.ClientTickEvent event) {

if (m.thePlayer != null) {

if (m.thePlayer.dimension == VoidMod.NullVoidDimID) {

if (m.thePlayer.inventory

.getCurrentItem() != null) {

if (m.thePlayer.inventory

.getCurrentItem().getItem()

.equals(VoidMod.baneOfDark)) {

m.gameSettings.gammaSetting = 1F;

} else {

m.gameSettings.gammaSetting = -1F;

}

} else {

m.gameSettings.gammaSetting = -1F;

}

} else {

if (m.gameSettings.gammaSetting == -1F) {

m.gameSettings.gammaSetting = Minecraft

.getMinecraft().thePlayer.getEntityData().getFloat(

"NullGamma");

}

}

}

}

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void texturePreStitch(TextureStitchEvent.Pre event) {

if (event.map.getTextureType() == 0) {

event.map.setTextureEntry("nullvoid:nullOre", VoidMod.texNullOre);

}

}

 

@SideOnly(Side.CLIENT)

@SubscribeEvent

public void renderGlitch(RenderGameOverlayEvent event) {

if (VoidMod.glitchAmulet != null

&& m.thePlayer != null) {

if (BaublesApi.getBaubles(m.thePlayer)

.getStackInSlot(0) != null) {

if (!BaublesApi.getBaubles(m.thePlayer)

.getStackInSlot(0)

.isItemEqual(new ItemStack(VoidMod.glitchAmulet))) {

glitch();

}

} else {

glitch();

}

}

}

 

@SubscribeEvent

public void crafted(ItemCraftedEvent event) {

if (event.crafting.getItem().equals(VoidMod.nullGoggles)) {

event.player.addStat(VoidMod.craftGoggle, 1);

}

}

 

private String getLetter() {

return String.valueOf(Character.toChars(r.nextInt(93) + 33));

}

 

private void glitch() {

if (m.thePlayer.dimension == VoidMod.NullVoidDimID) {

if (m.thePlayer.posX < 10

&& m.thePlayer.posX > -10

&& m.thePlayer.posZ < 10

&& m.thePlayer.posZ > -10) {

for (int i = 0; i < 10000; i++) {

m.fontRenderer

.drawString(getLetter(),

r.nextInt(m.displayWidth),

r.nextInt(m.displayWidth),

new Color(r.nextFloat(),

r.nextFloat(),

r.nextFloat()).getRGB());

}

} else if (m.thePlayer.posX < 50

&& m.thePlayer.posX > -50

&& m.thePlayer.posZ < 50

&& m.thePlayer.posZ > -50) {

for (int i = 0; i < 1000; i++) {

m.fontRenderer

.drawString(getLetter(),

r.nextInt(m.displayWidth),

r.nextInt(m.displayWidth),

new Color(r.nextFloat(),

r.nextFloat(),

r.nextFloat()).getRGB());

}

} else if (m.thePlayer.posX < 100

&& m.thePlayer.posX > -100

&& m.thePlayer.posZ < 100

&& m.thePlayer.posZ > -100) {

for (int i = 0; i < 100; i++) {

m.fontRenderer

.drawString(getLetter(),

r.nextInt(m.displayWidth),

r.nextInt(m.displayWidth),

new Color(r.nextFloat(),

r.nextFloat(),

r.nextFloat()).getRGB());

}

} else {

m.fontRenderer

.drawString(

getLetter(),

r.nextInt(m.displayWidth),

r.nextInt(m.displayHeight),

new Color(r.nextFloat(),

r.nextFloat(), r

.nextFloat()).getRGB());

}

}

}

}

 

 

Link to comment
Share on other sites

Ok, Thanks.

I am trying to change the player's gamma to -1F when they enter a dimension and revert it to their previous gamma when they exit. I already have it saving their gamma somewhere else, but I also need to revert it and make sure it is enforced if something does not work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.