001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.tridentsdk.server.data.block; 019 020import net.tridentsdk.base.Block; 021import net.tridentsdk.base.Substance; 022import net.tridentsdk.meta.block.CauldronMeta; 023import net.tridentsdk.meta.component.Meta; 024import net.tridentsdk.meta.component.MetaCollection; 025 026/** 027 * Implementation of the Cauldron Meta. 028 * 029 * @author The TridentSDK Team. 030 */ 031public class CauldronMetaImpl implements CauldronMeta { 032 private short filledLevel; 033 034 @Override 035 public short filledLevel() { 036 return filledLevel; 037 } 038 039 @Override 040 public void setFilledLevel(short level) { 041 this.filledLevel = level; 042 //Is it possible to update this for the players? 043 } 044 045 @Override 046 public double filledPercentage() { 047 return (filledLevel / 3) * 100; //3 is the max Short value for the water level in the cauldron. 048 } 049 050 @Override 051 public byte encode() { 052 return 0; 053 } 054 055 @Override 056 public Meta<Block> decode(Block instance, float yaw, byte direction, byte cx, byte cy, byte cz, short damageValue) { 057 instance.setSubstance(Substance.CAULDRON); 058 return this; 059 } 060 061 @Override 062 public Meta<Block> make() { 063 return new CauldronMetaImpl(); 064 } 065 066 @Override 067 public Substance[] applyTo(MetaCollection collection) { 068 collection.putIfAbsent(CauldronMeta.class, this); 069 return new Substance[] {Substance.CAULDRON}; 070 } 071}