use of net.minecraft.server.v1_13_R1.World in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_12_R1 method updateTileEntity.
@Override
public void updateTileEntity(Chest chest) {
Location loc = chest.getLocation();
World world = ((CraftWorld) loc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
TileEntity tileEntity = world.getTileEntity(blockPosition);
TileEntityWildChest tileEntityWildChest;
if (tileEntity instanceof TileEntityWildChest) {
tileEntityWildChest = (TileEntityWildChest) tileEntity;
((WChest) chest).setTileEntityContainer(tileEntityWildChest);
} else {
tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
}
world.setTileEntity(blockPosition, tileEntityWildChest);
}
use of net.minecraft.server.v1_13_R1.World in project PublicCrafters by BananaPuncher714.
the class CustomContainerWorkbench method shiftClick.
// Overrides 1.12.2
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
ItemStack itemstack = ItemStack.a;
Slot slot = (Slot) theseSlots.get(i);
if ((slot != null) && (slot.hasItem())) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if (i == 0) {
itemstack1.getItem().b(itemstack1, world, entityhuman);
if (!a(itemstack1, 10, 46, true)) {
return ItemStack.a;
}
slot.a(itemstack1, itemstack);
} else if ((i >= 10) && (i < 37)) {
if (!a(itemstack1, 37, 46, false)) {
return ItemStack.a;
}
} else if ((i >= 37) && (i < 46)) {
if (!a(itemstack1, 10, 37, false)) {
return ItemStack.a;
}
} else if (!a(itemstack1, 10, 46, false)) {
return ItemStack.a;
}
if (itemstack1.isEmpty()) {
slot.set(ItemStack.a);
} else {
slot.f();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.a;
}
ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
if (i == 0) {
entityhuman.drop(itemstack2, false);
}
}
return itemstack;
}
use of net.minecraft.server.v1_13_R1.World in project RoseStacker by Rosewood-Development.
the class StackedSpawnerTileImpl method updateTile.
private void updateTile() {
World level = this.a();
if (level != null) {
level.b(this.blockPos, this.blockEntity);
IBlockData var1 = this.a().getType(this.b());
this.a().notify(this.blockPos, var1, var1, 3);
}
}
use of net.minecraft.server.v1_13_R1.World in project RoseStacker by Rosewood-Development.
the class StackedSpawnerTileImpl method c.
@Override
public void c() {
World level = this.a();
if (level == null)
return;
// Only tick the spawner if a player is nearby
this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
if (this.playersTimeSinceLastCheck == 0)
this.playersNearby = this.isNearPlayer(level, this.blockPos);
if (!this.playersNearby)
return;
SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
// Handle redstone deactivation if enabled
if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
if (this.redstoneTimeSinceLastCheck == 0) {
boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
if (this.redstoneDeactivated && !hasSignal) {
this.redstoneDeactivated = false;
this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
this.updateTile();
} else if (!this.redstoneDeactivated && hasSignal) {
this.redstoneDeactivated = true;
this.requiredPlayerRange = 0;
this.updateTile();
}
if (this.redstoneDeactivated)
return;
}
this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
}
// Count down spawn timer unless we are ready to spawn
if (this.spawnDelay > 0) {
this.spawnDelay--;
return;
}
// Reset spawn delay
this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
this.updateTile();
// Execute spawning method
if (this.spawnData != null) {
MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
if (resourceLocation != null) {
NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
EntityType entityType = this.fromKey(namespacedKey);
if (entityType != null)
new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
}
}
// Randomize spawn potentials
if (!this.mobs.isEmpty())
this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
use of net.minecraft.server.v1_13_R1.World in project RoseStacker by Rosewood-Development.
the class StackedSpawnerTileImpl method c.
@Override
public void c() {
World level = this.a();
if (level == null)
return;
// Only tick the spawner if a player is nearby
this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
if (this.playersTimeSinceLastCheck == 0)
this.playersNearby = this.isNearPlayer(level, this.blockPos);
if (!this.playersNearby)
return;
SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
// Handle redstone deactivation if enabled
if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
if (this.redstoneTimeSinceLastCheck == 0) {
boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
if (this.redstoneDeactivated && !hasSignal) {
this.redstoneDeactivated = false;
this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
this.updateTile();
} else if (!this.redstoneDeactivated && hasSignal) {
this.redstoneDeactivated = true;
this.requiredPlayerRange = 0;
this.updateTile();
}
if (this.redstoneDeactivated)
return;
}
this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
}
// Count down spawn timer unless we are ready to spawn
if (this.spawnDelay > 0) {
this.spawnDelay--;
return;
}
// Reset spawn delay
this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
this.updateTile();
// Execute spawning method
if (this.spawnData != null) {
MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
if (resourceLocation != null) {
NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
EntityType entityType = this.fromKey(namespacedKey);
if (entityType != null)
new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
}
}
// Randomize spawn potentials
if (!this.mobs.isEmpty())
this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
Aggregations